<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>dinic: Fichero Fuente uthash.h</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generado por Doxygen 1.6.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Buscar');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Página&nbsp;principal</span></a></li>
      <li><a href="annotated.html"><span>Estructuras&nbsp;de&nbsp;Datos</span></a></li>
      <li class="current"><a href="files.html"><span>Archivos</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Buscar" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Lista&nbsp;de&nbsp;archivos</span></a></li>
      <li><a href="globals.html"><span>Globales</span></a></li>
    </ul>
  </div>
<h1>uthash.h</h1><a href="uthash_8h.html">Ir a la documentación de este archivo.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00005"></a>00005 <span class="comment">/*</span>
<a name="l00006"></a>00006 <span class="comment">Copyright (c) 2003-2010, Troy D. Hanson     http://uthash.sourceforge.net</span>
<a name="l00007"></a>00007 <span class="comment">All rights reserved.</span>
<a name="l00008"></a>00008 <span class="comment"></span>
<a name="l00009"></a>00009 <span class="comment">Redistribution and use in source and binary forms, with or without</span>
<a name="l00010"></a>00010 <span class="comment">modification, are permitted provided that the following conditions are met:</span>
<a name="l00011"></a>00011 <span class="comment"></span>
<a name="l00012"></a>00012 <span class="comment">    * Redistributions of source code must retain the above copyright</span>
<a name="l00013"></a>00013 <span class="comment">      notice, this list of conditions and the following disclaimer.</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS</span>
<a name="l00016"></a>00016 <span class="comment">IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED</span>
<a name="l00017"></a>00017 <span class="comment">TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A</span>
<a name="l00018"></a>00018 <span class="comment">PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER</span>
<a name="l00019"></a>00019 <span class="comment">OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,</span>
<a name="l00020"></a>00020 <span class="comment">EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,</span>
<a name="l00021"></a>00021 <span class="comment">PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR</span>
<a name="l00022"></a>00022 <span class="comment">PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF</span>
<a name="l00023"></a>00023 <span class="comment">LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING</span>
<a name="l00024"></a>00024 <span class="comment">NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS</span>
<a name="l00025"></a>00025 <span class="comment">SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00026"></a>00026 <span class="comment">*/</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#ifndef UTHASH_H</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#define UTHASH_H </span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;string.h&gt;</span>   <span class="comment">/* memcmp,strlen */</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;stddef.h&gt;</span>   <span class="comment">/* ptrdiff_t */</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="comment">/* These macros use decltype or the earlier __typeof GNU extension.</span>
<a name="l00035"></a>00035 <span class="comment">   As decltype is only available in newer compilers (VS2010 or gcc 4.3+</span>
<a name="l00036"></a>00036 <span class="comment">   when compiling c++ source) this code uses whatever method is needed</span>
<a name="l00037"></a>00037 <span class="comment">   or, for VS2008 where neither is available, uses casting workarounds. */</span>
<a name="l00038"></a>00038 <span class="preprocessor">#ifdef _MSC_VER         </span><span class="comment">/* MS compiler */</span>
<a name="l00039"></a>00039 <span class="preprocessor">#if _MSC_VER &gt;= 1600 &amp;&amp; defined(__cplusplus)  </span><span class="comment">/* VS2010 or newer in C++ mode */</span>
<a name="l00040"></a>00040 <span class="preprocessor">#define DECLTYPE(x) (decltype(x))</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#else                   </span><span class="comment">/* VS2008 or older (or VS2010 in C mode) */</span>
<a name="l00042"></a>00042 <span class="preprocessor">#define NO_DECLTYPE</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#define DECLTYPE(x)</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#else                   </span><span class="comment">/* GNU, Sun and other compilers */</span>
<a name="l00046"></a><a class="code" href="uthash_8h.html#a716ba290563c2d955cb0c90d85874073">00046</a> <span class="preprocessor">#define DECLTYPE(x) (__typeof(x))</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span>
<a name="l00049"></a>00049 <span class="preprocessor">#ifdef NO_DECLTYPE</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#define DECLTYPE_ASSIGN(dst,src)                                                 \</span>
<a name="l00051"></a>00051 <span class="preprocessor">do {                                                                             \</span>
<a name="l00052"></a>00052 <span class="preprocessor">  char **_da_dst = (char**)(&amp;(dst));                                             \</span>
<a name="l00053"></a>00053 <span class="preprocessor">  *_da_dst = (char*)(src);                                                       \</span>
<a name="l00054"></a>00054 <span class="preprocessor">} while(0)</span>
<a name="l00055"></a>00055 <span class="preprocessor"></span><span class="preprocessor">#else </span>
<a name="l00056"></a><a class="code" href="uthash_8h.html#a3c736f2f2dd643f2987b2bc323e269ba">00056</a> <span class="preprocessor"></span><span class="preprocessor">#define DECLTYPE_ASSIGN(dst,src)                                                 \</span>
<a name="l00057"></a>00057 <span class="preprocessor">do {                                                                             \</span>
<a name="l00058"></a>00058 <span class="preprocessor">  (dst) = DECLTYPE(dst)(src);                                                    \</span>
<a name="l00059"></a>00059 <span class="preprocessor">} while(0)</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span>
<a name="l00062"></a>00062 <span class="comment">/* a number of the hash function use uint32_t which isn&#39;t defined on win32 */</span>
<a name="l00063"></a>00063 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> uint32_t;
<a name="l00065"></a>00065 <span class="preprocessor">#else</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor">#include &lt;inttypes.h&gt;</span>   <span class="comment">/* uint32_t */</span>
<a name="l00067"></a>00067 <span class="preprocessor">#endif</span>
<a name="l00068"></a>00068 <span class="preprocessor"></span>
<a name="l00069"></a><a class="code" href="uthash_8h.html#aa56cef9cb86dc1f4b5d27ee3a691077e">00069</a> <span class="preprocessor">#define UTHASH_VERSION 1.9.3</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span>
<a name="l00071"></a><a class="code" href="uthash_8h.html#a03b52301b0ed976b6981ef33613320c1">00071</a> <span class="preprocessor">#define uthash_fatal(msg) exit(-1)        </span><span class="comment">/* fatal error (out of memory,etc) */</span>
<a name="l00072"></a><a class="code" href="uthash_8h.html#a861013aff36c0448f1888a2b0b5836d8">00072</a> <span class="preprocessor">#define uthash_malloc(sz) malloc(sz)      </span><span class="comment">/* malloc fcn                      */</span>
<a name="l00073"></a><a class="code" href="uthash_8h.html#a56cdf8c254fc700332c8e6a7263b4657">00073</a> <span class="preprocessor">#define uthash_free(ptr,sz) free(ptr)     </span><span class="comment">/* free fcn                        */</span>
<a name="l00074"></a>00074 
<a name="l00075"></a><a class="code" href="uthash_8h.html#a7cc237d8f87de3836b5390856cfc5c86">00075</a> <span class="preprocessor">#define uthash_noexpand_fyi(tbl)          </span><span class="comment">/* can be defined to log noexpand  */</span>
<a name="l00076"></a><a class="code" href="uthash_8h.html#a86ea78714da520989a6f7a764b4d71b4">00076</a> <span class="preprocessor">#define uthash_expand_fyi(tbl)            </span><span class="comment">/* can be defined to log expands   */</span>
<a name="l00077"></a>00077 
<a name="l00078"></a>00078 <span class="comment">/* initial number of buckets */</span>
<a name="l00079"></a><a class="code" href="uthash_8h.html#a361cdc5e8d6d8fe5fae6912588ae15d0">00079</a> <span class="preprocessor">#define HASH_INITIAL_NUM_BUCKETS 32      </span><span class="comment">/* initial number of buckets        */</span>
<a name="l00080"></a><a class="code" href="uthash_8h.html#a0b39a5cf1d6c05c43bd8530db2ec908c">00080</a> <span class="preprocessor">#define HASH_INITIAL_NUM_BUCKETS_LOG2 5  </span><span class="comment">/* lg2 of initial number of buckets */</span>
<a name="l00081"></a><a class="code" href="uthash_8h.html#a8ae3e6473261f6c4b78c030c94f5d68f">00081</a> <span class="preprocessor">#define HASH_BKT_CAPACITY_THRESH 10      </span><span class="comment">/* expand when bucket count reaches */</span>
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 <span class="comment">/* calculate the element whose hash handle address is hhe */</span>
<a name="l00084"></a><a class="code" href="uthash_8h.html#a568e95048979b8b3e4ea1567fd91c186">00084</a> <span class="preprocessor">#define ELMT_FROM_HH(tbl,hhp) ((void*)(((char*)(hhp)) - ((tbl)-&gt;hho)))</span>
<a name="l00085"></a>00085 <span class="preprocessor"></span>
<a name="l00086"></a><a class="code" href="uthash_8h.html#ad4a1cd39c3044936c0e49d3f372c9dbf">00086</a> <span class="preprocessor">#define HASH_FIND(hh,head,keyptr,keylen,out)                                     \</span>
<a name="l00087"></a>00087 <span class="preprocessor">do {                                                                             \</span>
<a name="l00088"></a>00088 <span class="preprocessor">  unsigned _hf_bkt,_hf_hashv;                                                    \</span>
<a name="l00089"></a>00089 <span class="preprocessor">  out=NULL;                                                                      \</span>
<a name="l00090"></a>00090 <span class="preprocessor">  if (head) {                                                                    \</span>
<a name="l00091"></a>00091 <span class="preprocessor">     HASH_FCN(keyptr,keylen, (head)-&gt;hh.tbl-&gt;num_buckets, _hf_hashv, _hf_bkt);   \</span>
<a name="l00092"></a>00092 <span class="preprocessor">     if (HASH_BLOOM_TEST((head)-&gt;hh.tbl, _hf_hashv)) {                           \</span>
<a name="l00093"></a>00093 <span class="preprocessor">       HASH_FIND_IN_BKT((head)-&gt;hh.tbl, hh, (head)-&gt;hh.tbl-&gt;buckets[ _hf_bkt ],  \</span>
<a name="l00094"></a>00094 <span class="preprocessor">                        keyptr,keylen,out);                                      \</span>
<a name="l00095"></a>00095 <span class="preprocessor">     }                                                                           \</span>
<a name="l00096"></a>00096 <span class="preprocessor">  }                                                                              \</span>
<a name="l00097"></a>00097 <span class="preprocessor">} while (0)</span>
<a name="l00098"></a>00098 <span class="preprocessor"></span>
<a name="l00099"></a>00099 <span class="preprocessor">#ifdef HASH_BLOOM</span>
<a name="l00100"></a>00100 <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_BITLEN (1ULL &lt;&lt; HASH_BLOOM)</span>
<a name="l00101"></a>00101 <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_BYTELEN (HASH_BLOOM_BITLEN/8) + ((HASH_BLOOM_BITLEN%8) ? 1:0)</span>
<a name="l00102"></a>00102 <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_MAKE(tbl)                                                     \</span>
<a name="l00103"></a>00103 <span class="preprocessor">do {                                                                             \</span>
<a name="l00104"></a>00104 <span class="preprocessor">  (tbl)-&gt;bloom_nbits = HASH_BLOOM;                                               \</span>
<a name="l00105"></a>00105 <span class="preprocessor">  (tbl)-&gt;bloom_bv = (uint8_t*)uthash_malloc(HASH_BLOOM_BYTELEN);                 \</span>
<a name="l00106"></a>00106 <span class="preprocessor">  if (!((tbl)-&gt;bloom_bv))  { uthash_fatal( &quot;out of memory&quot;); }                   \</span>
<a name="l00107"></a>00107 <span class="preprocessor">  memset((tbl)-&gt;bloom_bv, 0, HASH_BLOOM_BYTELEN);                                \</span>
<a name="l00108"></a>00108 <span class="preprocessor">  (tbl)-&gt;bloom_sig = HASH_BLOOM_SIGNATURE;                                       \</span>
<a name="l00109"></a>00109 <span class="preprocessor">} while (0);</span>
<a name="l00110"></a>00110 <span class="preprocessor"></span>
<a name="l00111"></a>00111 <span class="preprocessor">#define HASH_BLOOM_FREE(tbl)                                                     \</span>
<a name="l00112"></a>00112 <span class="preprocessor">do {                                                                             \</span>
<a name="l00113"></a>00113 <span class="preprocessor">  uthash_free((tbl)-&gt;bloom_bv, HASH_BLOOM_BYTELEN);                              \</span>
<a name="l00114"></a>00114 <span class="preprocessor">} while (0);</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span>
<a name="l00116"></a>00116 <span class="preprocessor">#define HASH_BLOOM_BITSET(bv,idx) (bv[(idx)/8] |= (1U &lt;&lt; ((idx)%8)))</span>
<a name="l00117"></a>00117 <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_BITTEST(bv,idx) (bv[(idx)/8] &amp; (1U &lt;&lt; ((idx)%8)))</span>
<a name="l00118"></a>00118 <span class="preprocessor"></span>
<a name="l00119"></a>00119 <span class="preprocessor">#define HASH_BLOOM_ADD(tbl,hashv)                                                \</span>
<a name="l00120"></a>00120 <span class="preprocessor">  HASH_BLOOM_BITSET((tbl)-&gt;bloom_bv, (hashv &amp; (uint32_t)((1ULL &lt;&lt; (tbl)-&gt;bloom_nbits) - 1)))</span>
<a name="l00121"></a>00121 <span class="preprocessor"></span>
<a name="l00122"></a>00122 <span class="preprocessor">#define HASH_BLOOM_TEST(tbl,hashv)                                               \</span>
<a name="l00123"></a>00123 <span class="preprocessor">  HASH_BLOOM_BITTEST((tbl)-&gt;bloom_bv, (hashv &amp; (uint32_t)((1ULL &lt;&lt; (tbl)-&gt;bloom_nbits) - 1)))</span>
<a name="l00124"></a>00124 <span class="preprocessor"></span>
<a name="l00125"></a>00125 <span class="preprocessor">#else</span>
<a name="l00126"></a><a class="code" href="uthash_8h.html#a254f427772a1fe7a2480a8302af8f8b8">00126</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_MAKE(tbl) </span>
<a name="l00127"></a><a class="code" href="uthash_8h.html#ad6847ad938fc26bfd0726d7f159efd0a">00127</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_FREE(tbl) </span>
<a name="l00128"></a><a class="code" href="uthash_8h.html#acaad947212056cd8bfe3d660265fb2db">00128</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_ADD(tbl,hashv) </span>
<a name="l00129"></a><a class="code" href="uthash_8h.html#a06bfbf880899d54da35487d0d39c1009">00129</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_TEST(tbl,hashv) (1)</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00131"></a>00131 <span class="preprocessor"></span>
<a name="l00132"></a><a class="code" href="uthash_8h.html#aeba971430f623b6334f565d9c7ec9de5">00132</a> <span class="preprocessor">#define HASH_MAKE_TABLE(hh,head)                                                 \</span>
<a name="l00133"></a>00133 <span class="preprocessor">do {                                                                             \</span>
<a name="l00134"></a>00134 <span class="preprocessor">  (head)-&gt;hh.tbl = (UT_hash_table*)uthash_malloc(                                \</span>
<a name="l00135"></a>00135 <span class="preprocessor">                  sizeof(UT_hash_table));                                        \</span>
<a name="l00136"></a>00136 <span class="preprocessor">  if (!((head)-&gt;hh.tbl))  { uthash_fatal( &quot;out of memory&quot;); }                    \</span>
<a name="l00137"></a>00137 <span class="preprocessor">  memset((head)-&gt;hh.tbl, 0, sizeof(UT_hash_table));                              \</span>
<a name="l00138"></a>00138 <span class="preprocessor">  (head)-&gt;hh.tbl-&gt;tail = &amp;((head)-&gt;hh);                                          \</span>
<a name="l00139"></a>00139 <span class="preprocessor">  (head)-&gt;hh.tbl-&gt;num_buckets = HASH_INITIAL_NUM_BUCKETS;                        \</span>
<a name="l00140"></a>00140 <span class="preprocessor">  (head)-&gt;hh.tbl-&gt;log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2;              \</span>
<a name="l00141"></a>00141 <span class="preprocessor">  (head)-&gt;hh.tbl-&gt;hho = (char*)(&amp;(head)-&gt;hh) - (char*)(head);                    \</span>
<a name="l00142"></a>00142 <span class="preprocessor">  (head)-&gt;hh.tbl-&gt;buckets = (UT_hash_bucket*)uthash_malloc(                      \</span>
<a name="l00143"></a>00143 <span class="preprocessor">          HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));               \</span>
<a name="l00144"></a>00144 <span class="preprocessor">  if (! (head)-&gt;hh.tbl-&gt;buckets) { uthash_fatal( &quot;out of memory&quot;); }             \</span>
<a name="l00145"></a>00145 <span class="preprocessor">  memset((head)-&gt;hh.tbl-&gt;buckets, 0,                                             \</span>
<a name="l00146"></a>00146 <span class="preprocessor">          HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket));               \</span>
<a name="l00147"></a>00147 <span class="preprocessor">  HASH_BLOOM_MAKE((head)-&gt;hh.tbl);                                               \</span>
<a name="l00148"></a>00148 <span class="preprocessor">  (head)-&gt;hh.tbl-&gt;signature = HASH_SIGNATURE;                                    \</span>
<a name="l00149"></a>00149 <span class="preprocessor">} while(0)</span>
<a name="l00150"></a>00150 <span class="preprocessor"></span>
<a name="l00151"></a><a class="code" href="uthash_8h.html#aaf01358e257c8d838eb5e4b189f0c399">00151</a> <span class="preprocessor">#define HASH_ADD(hh,head,fieldname,keylen_in,add)                                \</span>
<a name="l00152"></a>00152 <span class="preprocessor">        HASH_ADD_KEYPTR(hh,head,&amp;add-&gt;fieldname,keylen_in,add)</span>
<a name="l00153"></a>00153 <span class="preprocessor"></span> 
<a name="l00154"></a><a class="code" href="uthash_8h.html#a0b7468360b5c788762cdb2ccf9cd4d26">00154</a> <span class="preprocessor">#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add)                            \</span>
<a name="l00155"></a>00155 <span class="preprocessor">do {                                                                             \</span>
<a name="l00156"></a>00156 <span class="preprocessor"> unsigned _ha_bkt;                                                               \</span>
<a name="l00157"></a>00157 <span class="preprocessor"> (add)-&gt;hh.next = NULL;                                                          \</span>
<a name="l00158"></a>00158 <span class="preprocessor"> (add)-&gt;hh.key = (char*)keyptr;                                                  \</span>
<a name="l00159"></a>00159 <span class="preprocessor"> (add)-&gt;hh.keylen = keylen_in;                                                   \</span>
<a name="l00160"></a>00160 <span class="preprocessor"> if (!(head)) {                                                                  \</span>
<a name="l00161"></a>00161 <span class="preprocessor">    head = (add);                                                                \</span>
<a name="l00162"></a>00162 <span class="preprocessor">    (head)-&gt;hh.prev = NULL;                                                      \</span>
<a name="l00163"></a>00163 <span class="preprocessor">    HASH_MAKE_TABLE(hh,head);                                                    \</span>
<a name="l00164"></a>00164 <span class="preprocessor"> } else {                                                                        \</span>
<a name="l00165"></a>00165 <span class="preprocessor">    (head)-&gt;hh.tbl-&gt;tail-&gt;next = (add);                                          \</span>
<a name="l00166"></a>00166 <span class="preprocessor">    (add)-&gt;hh.prev = ELMT_FROM_HH((head)-&gt;hh.tbl, (head)-&gt;hh.tbl-&gt;tail);         \</span>
<a name="l00167"></a>00167 <span class="preprocessor">    (head)-&gt;hh.tbl-&gt;tail = &amp;((add)-&gt;hh);                                         \</span>
<a name="l00168"></a>00168 <span class="preprocessor"> }                                                                               \</span>
<a name="l00169"></a>00169 <span class="preprocessor"> (head)-&gt;hh.tbl-&gt;num_items++;                                                    \</span>
<a name="l00170"></a>00170 <span class="preprocessor"> (add)-&gt;hh.tbl = (head)-&gt;hh.tbl;                                                 \</span>
<a name="l00171"></a>00171 <span class="preprocessor"> HASH_FCN(keyptr,keylen_in, (head)-&gt;hh.tbl-&gt;num_buckets,                         \</span>
<a name="l00172"></a>00172 <span class="preprocessor">         (add)-&gt;hh.hashv, _ha_bkt);                                              \</span>
<a name="l00173"></a>00173 <span class="preprocessor"> HASH_ADD_TO_BKT((head)-&gt;hh.tbl-&gt;buckets[_ha_bkt],&amp;(add)-&gt;hh);                   \</span>
<a name="l00174"></a>00174 <span class="preprocessor"> HASH_BLOOM_ADD((head)-&gt;hh.tbl,(add)-&gt;hh.hashv);                                 \</span>
<a name="l00175"></a>00175 <span class="preprocessor"> HASH_EMIT_KEY(hh,head,keyptr,keylen_in);                                        \</span>
<a name="l00176"></a>00176 <span class="preprocessor"> HASH_FSCK(hh,head);                                                             \</span>
<a name="l00177"></a>00177 <span class="preprocessor">} while(0)</span>
<a name="l00178"></a>00178 <span class="preprocessor"></span>
<a name="l00179"></a><a class="code" href="uthash_8h.html#a4d7691544128a6ef265f3e4fa5ed3113">00179</a> <span class="preprocessor">#define HASH_TO_BKT( hashv, num_bkts, bkt )                                      \</span>
<a name="l00180"></a>00180 <span class="preprocessor">do {                                                                             \</span>
<a name="l00181"></a>00181 <span class="preprocessor">  bkt = ((hashv) &amp; ((num_bkts) - 1));                                            \</span>
<a name="l00182"></a>00182 <span class="preprocessor">} while(0)</span>
<a name="l00183"></a>00183 <span class="preprocessor"></span>
<a name="l00184"></a>00184 <span class="comment">/* delete &quot;delptr&quot; from the hash table.</span>
<a name="l00185"></a>00185 <span class="comment"> * &quot;the usual&quot; patch-up process for the app-order doubly-linked-list.</span>
<a name="l00186"></a>00186 <span class="comment"> * The use of _hd_hh_del below deserves special explanation.</span>
<a name="l00187"></a>00187 <span class="comment"> * These used to be expressed using (delptr) but that led to a bug</span>
<a name="l00188"></a>00188 <span class="comment"> * if someone used the same symbol for the head and deletee, like</span>
<a name="l00189"></a>00189 <span class="comment"> *  HASH_DELETE(hh,users,users);</span>
<a name="l00190"></a>00190 <span class="comment"> * We want that to work, but by changing the head (users) below</span>
<a name="l00191"></a>00191 <span class="comment"> * we were forfeiting our ability to further refer to the deletee (users)</span>
<a name="l00192"></a>00192 <span class="comment"> * in the patch-up process. Solution: use scratch space to</span>
<a name="l00193"></a>00193 <span class="comment"> * copy the deletee pointer, then the latter references are via that</span>
<a name="l00194"></a>00194 <span class="comment"> * scratch pointer rather than through the repointed (users) symbol.</span>
<a name="l00195"></a>00195 <span class="comment"> */</span>
<a name="l00196"></a><a class="code" href="uthash_8h.html#a3f83117e1108d63844a58d2d79c3b980">00196</a> <span class="preprocessor">#define HASH_DELETE(hh,head,delptr)                                              \</span>
<a name="l00197"></a>00197 <span class="preprocessor">do {                                                                             \</span>
<a name="l00198"></a>00198 <span class="preprocessor">    unsigned _hd_bkt;                                                            \</span>
<a name="l00199"></a>00199 <span class="preprocessor">    struct UT_hash_handle *_hd_hh_del;                                           \</span>
<a name="l00200"></a>00200 <span class="preprocessor">    if ( ((delptr)-&gt;hh.prev == NULL) &amp;&amp; ((delptr)-&gt;hh.next == NULL) )  {         \</span>
<a name="l00201"></a>00201 <span class="preprocessor">        uthash_free((head)-&gt;hh.tbl-&gt;buckets,                                     \</span>
<a name="l00202"></a>00202 <span class="preprocessor">                    (head)-&gt;hh.tbl-&gt;num_buckets*sizeof(struct UT_hash_bucket) ); \</span>
<a name="l00203"></a>00203 <span class="preprocessor">        HASH_BLOOM_FREE((head)-&gt;hh.tbl);                                         \</span>
<a name="l00204"></a>00204 <span class="preprocessor">        uthash_free((head)-&gt;hh.tbl, sizeof(UT_hash_table));                      \</span>
<a name="l00205"></a>00205 <span class="preprocessor">        head = NULL;                                                             \</span>
<a name="l00206"></a>00206 <span class="preprocessor">    } else {                                                                     \</span>
<a name="l00207"></a>00207 <span class="preprocessor">        _hd_hh_del = &amp;((delptr)-&gt;hh);                                            \</span>
<a name="l00208"></a>00208 <span class="preprocessor">        if ((delptr) == ELMT_FROM_HH((head)-&gt;hh.tbl,(head)-&gt;hh.tbl-&gt;tail)) {     \</span>
<a name="l00209"></a>00209 <span class="preprocessor">            (head)-&gt;hh.tbl-&gt;tail =                                               \</span>
<a name="l00210"></a>00210 <span class="preprocessor">                (UT_hash_handle*)((char*)((delptr)-&gt;hh.prev) +                   \</span>
<a name="l00211"></a>00211 <span class="preprocessor">                (head)-&gt;hh.tbl-&gt;hho);                                            \</span>
<a name="l00212"></a>00212 <span class="preprocessor">        }                                                                        \</span>
<a name="l00213"></a>00213 <span class="preprocessor">        if ((delptr)-&gt;hh.prev) {                                                 \</span>
<a name="l00214"></a>00214 <span class="preprocessor">            ((UT_hash_handle*)((char*)((delptr)-&gt;hh.prev) +                      \</span>
<a name="l00215"></a>00215 <span class="preprocessor">                    (head)-&gt;hh.tbl-&gt;hho))-&gt;next = (delptr)-&gt;hh.next;             \</span>
<a name="l00216"></a>00216 <span class="preprocessor">        } else {                                                                 \</span>
<a name="l00217"></a>00217 <span class="preprocessor">            DECLTYPE_ASSIGN(head,(delptr)-&gt;hh.next);                             \</span>
<a name="l00218"></a>00218 <span class="preprocessor">        }                                                                        \</span>
<a name="l00219"></a>00219 <span class="preprocessor">        if (_hd_hh_del-&gt;next) {                                                  \</span>
<a name="l00220"></a>00220 <span class="preprocessor">            ((UT_hash_handle*)((char*)_hd_hh_del-&gt;next +                         \</span>
<a name="l00221"></a>00221 <span class="preprocessor">                    (head)-&gt;hh.tbl-&gt;hho))-&gt;prev =                                \</span>
<a name="l00222"></a>00222 <span class="preprocessor">                    _hd_hh_del-&gt;prev;                                            \</span>
<a name="l00223"></a>00223 <span class="preprocessor">        }                                                                        \</span>
<a name="l00224"></a>00224 <span class="preprocessor">        HASH_TO_BKT( _hd_hh_del-&gt;hashv, (head)-&gt;hh.tbl-&gt;num_buckets, _hd_bkt);   \</span>
<a name="l00225"></a>00225 <span class="preprocessor">        HASH_DEL_IN_BKT(hh,(head)-&gt;hh.tbl-&gt;buckets[_hd_bkt], _hd_hh_del);        \</span>
<a name="l00226"></a>00226 <span class="preprocessor">        (head)-&gt;hh.tbl-&gt;num_items--;                                             \</span>
<a name="l00227"></a>00227 <span class="preprocessor">    }                                                                            \</span>
<a name="l00228"></a>00228 <span class="preprocessor">    HASH_FSCK(hh,head);                                                          \</span>
<a name="l00229"></a>00229 <span class="preprocessor">} while (0)</span>
<a name="l00230"></a>00230 <span class="preprocessor"></span>
<a name="l00231"></a>00231 
<a name="l00232"></a>00232 <span class="comment">/* convenience forms of HASH_FIND/HASH_ADD/HASH_DEL */</span>
<a name="l00233"></a><a class="code" href="uthash_8h.html#a214529083adfab2fa8cd402d2eeb0a84">00233</a> <span class="preprocessor">#define HASH_FIND_STR(head,findstr,out)                                          \</span>
<a name="l00234"></a>00234 <span class="preprocessor">    HASH_FIND(hh,head,findstr,strlen(findstr),out)</span>
<a name="l00235"></a><a class="code" href="uthash_8h.html#a9724951736f3985f74df17638c8a7885">00235</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_ADD_STR(head,strfield,add)                                          \</span>
<a name="l00236"></a>00236 <span class="preprocessor">    HASH_ADD(hh,head,strfield,strlen(add-&gt;strfield),add)</span>
<a name="l00237"></a><a class="code" href="uthash_8h.html#aadcb19b940348f3141bd51505ede0142">00237</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_FIND_INT(head,findint,out)                                          \</span>
<a name="l00238"></a>00238 <span class="preprocessor">    HASH_FIND(hh,head,findint,sizeof(int),out)</span>
<a name="l00239"></a><a class="code" href="uthash_8h.html#acf85835471af894e354efb7e346698f3">00239</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_ADD_INT(head,intfield,add)                                          \</span>
<a name="l00240"></a>00240 <span class="preprocessor">    HASH_ADD(hh,head,intfield,sizeof(int),add)</span>
<a name="l00241"></a><a class="code" href="uthash_8h.html#a26a887f8e31952034becac0cf446f6c3">00241</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_FIND_PTR(head,findptr,out)                                          \</span>
<a name="l00242"></a>00242 <span class="preprocessor">    HASH_FIND(hh,head,findptr,sizeof(void *),out)</span>
<a name="l00243"></a><a class="code" href="uthash_8h.html#a2ad1f84ef1ba9df99fa2ada38cb61823">00243</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_ADD_PTR(head,ptrfield,add)                                          \</span>
<a name="l00244"></a>00244 <span class="preprocessor">    HASH_ADD(hh,head,ptrfield,sizeof(void *),add)</span>
<a name="l00245"></a><a class="code" href="uthash_8h.html#a48b7ed374602dcb236501aa23a971f05">00245</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_DEL(head,delptr)                                                    \</span>
<a name="l00246"></a>00246 <span class="preprocessor">    HASH_DELETE(hh,head,delptr)</span>
<a name="l00247"></a>00247 <span class="preprocessor"></span>
<a name="l00248"></a>00248 <span class="comment">/* HASH_FSCK checks hash integrity on every add/delete when HASH_DEBUG is defined.</span>
<a name="l00249"></a>00249 <span class="comment"> * This is for uthash developer only; it compiles away if HASH_DEBUG isn&#39;t defined.</span>
<a name="l00250"></a>00250 <span class="comment"> */</span>
<a name="l00251"></a>00251 <span class="preprocessor">#ifdef HASH_DEBUG</span>
<a name="l00252"></a>00252 <span class="preprocessor"></span><span class="preprocessor">#define HASH_OOPS(...) do { fprintf(stderr,__VA_ARGS__); exit(-1); } while (0)</span>
<a name="l00253"></a>00253 <span class="preprocessor"></span><span class="preprocessor">#define HASH_FSCK(hh,head)                                                       \</span>
<a name="l00254"></a>00254 <span class="preprocessor">do {                                                                             \</span>
<a name="l00255"></a>00255 <span class="preprocessor">    unsigned _bkt_i;                                                             \</span>
<a name="l00256"></a>00256 <span class="preprocessor">    unsigned _count, _bkt_count;                                                 \</span>
<a name="l00257"></a>00257 <span class="preprocessor">    char *_prev;                                                                 \</span>
<a name="l00258"></a>00258 <span class="preprocessor">    struct UT_hash_handle *_thh;                                                 \</span>
<a name="l00259"></a>00259 <span class="preprocessor">    if (head) {                                                                  \</span>
<a name="l00260"></a>00260 <span class="preprocessor">        _count = 0;                                                              \</span>
<a name="l00261"></a>00261 <span class="preprocessor">        for( _bkt_i = 0; _bkt_i &lt; (head)-&gt;hh.tbl-&gt;num_buckets; _bkt_i++) {       \</span>
<a name="l00262"></a>00262 <span class="preprocessor">            _bkt_count = 0;                                                      \</span>
<a name="l00263"></a>00263 <span class="preprocessor">            _thh = (head)-&gt;hh.tbl-&gt;buckets[_bkt_i].hh_head;                      \</span>
<a name="l00264"></a>00264 <span class="preprocessor">            _prev = NULL;                                                        \</span>
<a name="l00265"></a>00265 <span class="preprocessor">            while (_thh) {                                                       \</span>
<a name="l00266"></a>00266 <span class="preprocessor">               if (_prev != (char*)(_thh-&gt;hh_prev)) {                            \</span>
<a name="l00267"></a>00267 <span class="preprocessor">                   HASH_OOPS(&quot;invalid hh_prev %p, actual %p\n&quot;,                  \</span>
<a name="l00268"></a>00268 <span class="preprocessor">                    _thh-&gt;hh_prev, _prev );                                      \</span>
<a name="l00269"></a>00269 <span class="preprocessor">               }                                                                 \</span>
<a name="l00270"></a>00270 <span class="preprocessor">               _bkt_count++;                                                     \</span>
<a name="l00271"></a>00271 <span class="preprocessor">               _prev = (char*)(_thh);                                            \</span>
<a name="l00272"></a>00272 <span class="preprocessor">               _thh = _thh-&gt;hh_next;                                             \</span>
<a name="l00273"></a>00273 <span class="preprocessor">            }                                                                    \</span>
<a name="l00274"></a>00274 <span class="preprocessor">            _count += _bkt_count;                                                \</span>
<a name="l00275"></a>00275 <span class="preprocessor">            if ((head)-&gt;hh.tbl-&gt;buckets[_bkt_i].count !=  _bkt_count) {          \</span>
<a name="l00276"></a>00276 <span class="preprocessor">               HASH_OOPS(&quot;invalid bucket count %d, actual %d\n&quot;,                 \</span>
<a name="l00277"></a>00277 <span class="preprocessor">                (head)-&gt;hh.tbl-&gt;buckets[_bkt_i].count, _bkt_count);              \</span>
<a name="l00278"></a>00278 <span class="preprocessor">            }                                                                    \</span>
<a name="l00279"></a>00279 <span class="preprocessor">        }                                                                        \</span>
<a name="l00280"></a>00280 <span class="preprocessor">        if (_count != (head)-&gt;hh.tbl-&gt;num_items) {                               \</span>
<a name="l00281"></a>00281 <span class="preprocessor">            HASH_OOPS(&quot;invalid hh item count %d, actual %d\n&quot;,                   \</span>
<a name="l00282"></a>00282 <span class="preprocessor">                (head)-&gt;hh.tbl-&gt;num_items, _count );                             \</span>
<a name="l00283"></a>00283 <span class="preprocessor">        }                                                                        \</span>
<a name="l00284"></a>00284 <span class="preprocessor">        </span><span class="comment">/* traverse hh in app order; check next/prev integrity, count */</span>         \
<a name="l00285"></a>00285         _count = 0;                                                              \
<a name="l00286"></a>00286         _prev = NULL;                                                            \
<a name="l00287"></a>00287         _thh =  &amp;(head)-&gt;hh;                                                     \
<a name="l00288"></a>00288         while (_thh) {                                                           \
<a name="l00289"></a>00289            _count++;                                                             \
<a name="l00290"></a>00290            if (_prev !=(char*)(_thh-&gt;prev)) {                                    \
<a name="l00291"></a>00291               HASH_OOPS(&quot;invalid prev %p, actual %p\n&quot;,                          \
<a name="l00292"></a>00292                     _thh-&gt;prev, _prev );                                         \
<a name="l00293"></a>00293            }                                                                     \
<a name="l00294"></a>00294            _prev = (char*)ELMT_FROM_HH((head)-&gt;hh.tbl, _thh);                    \
<a name="l00295"></a>00295            _thh = ( _thh-&gt;next ?  (UT_hash_handle*)((char*)(_thh-&gt;next) +        \
<a name="l00296"></a>00296                                   (head)-&gt;hh.tbl-&gt;hho) : NULL );                 \
<a name="l00297"></a>00297         }                                                                        \
<a name="l00298"></a>00298         if (_count != (head)-&gt;hh.tbl-&gt;num_items) {                               \
<a name="l00299"></a>00299             HASH_OOPS(&quot;invalid app item count %d, actual %d\n&quot;,                  \
<a name="l00300"></a>00300                 (head)-&gt;hh.tbl-&gt;num_items, _count );                             \
<a name="l00301"></a>00301         }                                                                        \
<a name="l00302"></a>00302     }                                                                            \
<a name="l00303"></a>00303 } while (0)
<a name="l00304"></a>00304 <span class="preprocessor">#else</span>
<a name="l00305"></a><a class="code" href="uthash_8h.html#a7d882fadb26a4e6c13c134d8be4d0759">00305</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_FSCK(hh,head) </span>
<a name="l00306"></a>00306 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00307"></a>00307 <span class="preprocessor"></span>
<a name="l00308"></a>00308 <span class="comment">/* When compiled with -DHASH_EMIT_KEYS, length-prefixed keys are emitted to </span>
<a name="l00309"></a>00309 <span class="comment"> * the descriptor to which this macro is defined for tuning the hash function.</span>
<a name="l00310"></a>00310 <span class="comment"> * The app can #include &lt;unistd.h&gt; to get the prototype for write(2). */</span>
<a name="l00311"></a>00311 <span class="preprocessor">#ifdef HASH_EMIT_KEYS</span>
<a name="l00312"></a>00312 <span class="preprocessor"></span><span class="preprocessor">#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)                                   \</span>
<a name="l00313"></a>00313 <span class="preprocessor">do {                                                                             \</span>
<a name="l00314"></a>00314 <span class="preprocessor">    unsigned _klen = fieldlen;                                                   \</span>
<a name="l00315"></a>00315 <span class="preprocessor">    write(HASH_EMIT_KEYS, &amp;_klen, sizeof(_klen));                                \</span>
<a name="l00316"></a>00316 <span class="preprocessor">    write(HASH_EMIT_KEYS, keyptr, fieldlen);                                     \</span>
<a name="l00317"></a>00317 <span class="preprocessor">} while (0)</span>
<a name="l00318"></a>00318 <span class="preprocessor"></span><span class="preprocessor">#else </span>
<a name="l00319"></a><a class="code" href="uthash_8h.html#a44f9d46e2cc79652492e5dd3e6c40a15">00319</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_EMIT_KEY(hh,head,keyptr,fieldlen)                    </span>
<a name="l00320"></a>00320 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00321"></a>00321 <span class="preprocessor"></span>
<a name="l00322"></a>00322 <span class="comment">/* default to Jenkin&#39;s hash unless overridden e.g. DHASH_FUNCTION=HASH_SAX */</span>
<a name="l00323"></a>00323 <span class="preprocessor">#ifdef HASH_FUNCTION </span>
<a name="l00324"></a>00324 <span class="preprocessor"></span><span class="preprocessor">#define HASH_FCN HASH_FUNCTION</span>
<a name="l00325"></a>00325 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00326"></a><a class="code" href="uthash_8h.html#abd3356419b386c379116393700a751d3">00326</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_FCN HASH_JEN</span>
<a name="l00327"></a>00327 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00328"></a>00328 <span class="preprocessor"></span>
<a name="l00329"></a>00329 <span class="comment">/* The Bernstein hash function, used in Perl prior to v5.6 */</span>
<a name="l00330"></a><a class="code" href="uthash_8h.html#a7271bf51d7fe2cf2c183578aee73601e">00330</a> <span class="preprocessor">#define HASH_BER(key,keylen,num_bkts,hashv,bkt)                                  \</span>
<a name="l00331"></a>00331 <span class="preprocessor">do {                                                                             \</span>
<a name="l00332"></a>00332 <span class="preprocessor">  unsigned _hb_keylen=keylen;                                                    \</span>
<a name="l00333"></a>00333 <span class="preprocessor">  char *_hb_key=(char*)(key);                                                    \</span>
<a name="l00334"></a>00334 <span class="preprocessor">  (hashv) = 0;                                                                   \</span>
<a name="l00335"></a>00335 <span class="preprocessor">  while (_hb_keylen--)  { (hashv) = ((hashv) * 33) + *_hb_key++; }               \</span>
<a name="l00336"></a>00336 <span class="preprocessor">  bkt = (hashv) &amp; (num_bkts-1);                                                  \</span>
<a name="l00337"></a>00337 <span class="preprocessor">} while (0)</span>
<a name="l00338"></a>00338 <span class="preprocessor"></span>
<a name="l00339"></a>00339 
<a name="l00340"></a>00340 <span class="comment">/* SAX/FNV/OAT/JEN hash functions are macro variants of those listed at </span>
<a name="l00341"></a>00341 <span class="comment"> * http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx */</span>
<a name="l00342"></a><a class="code" href="uthash_8h.html#aa4cb140b45415e7bf57237525388af79">00342</a> <span class="preprocessor">#define HASH_SAX(key,keylen,num_bkts,hashv,bkt)                                  \</span>
<a name="l00343"></a>00343 <span class="preprocessor">do {                                                                             \</span>
<a name="l00344"></a>00344 <span class="preprocessor">  unsigned _sx_i;                                                                \</span>
<a name="l00345"></a>00345 <span class="preprocessor">  char *_hs_key=(char*)(key);                                                    \</span>
<a name="l00346"></a>00346 <span class="preprocessor">  hashv = 0;                                                                     \</span>
<a name="l00347"></a>00347 <span class="preprocessor">  for(_sx_i=0; _sx_i &lt; keylen; _sx_i++)                                          \</span>
<a name="l00348"></a>00348 <span class="preprocessor">      hashv ^= (hashv &lt;&lt; 5) + (hashv &gt;&gt; 2) + _hs_key[_sx_i];                     \</span>
<a name="l00349"></a>00349 <span class="preprocessor">  bkt = hashv &amp; (num_bkts-1);                                                    \</span>
<a name="l00350"></a>00350 <span class="preprocessor">} while (0)</span>
<a name="l00351"></a>00351 <span class="preprocessor"></span>
<a name="l00352"></a><a class="code" href="uthash_8h.html#ac99f9a353421537527a80b392089dd9d">00352</a> <span class="preprocessor">#define HASH_FNV(key,keylen,num_bkts,hashv,bkt)                                  \</span>
<a name="l00353"></a>00353 <span class="preprocessor">do {                                                                             \</span>
<a name="l00354"></a>00354 <span class="preprocessor">  unsigned _fn_i;                                                                \</span>
<a name="l00355"></a>00355 <span class="preprocessor">  char *_hf_key=(char*)(key);                                                    \</span>
<a name="l00356"></a>00356 <span class="preprocessor">  hashv = 2166136261UL;                                                          \</span>
<a name="l00357"></a>00357 <span class="preprocessor">  for(_fn_i=0; _fn_i &lt; keylen; _fn_i++)                                          \</span>
<a name="l00358"></a>00358 <span class="preprocessor">      hashv = (hashv * 16777619) ^ _hf_key[_fn_i];                               \</span>
<a name="l00359"></a>00359 <span class="preprocessor">  bkt = hashv &amp; (num_bkts-1);                                                    \</span>
<a name="l00360"></a>00360 <span class="preprocessor">} while(0);</span>
<a name="l00361"></a>00361 <span class="preprocessor"></span> 
<a name="l00362"></a><a class="code" href="uthash_8h.html#abc7040b698211c1993441fb4165fa0b4">00362</a> <span class="preprocessor">#define HASH_OAT(key,keylen,num_bkts,hashv,bkt)                                  \</span>
<a name="l00363"></a>00363 <span class="preprocessor">do {                                                                             \</span>
<a name="l00364"></a>00364 <span class="preprocessor">  unsigned _ho_i;                                                                \</span>
<a name="l00365"></a>00365 <span class="preprocessor">  char *_ho_key=(char*)(key);                                                    \</span>
<a name="l00366"></a>00366 <span class="preprocessor">  hashv = 0;                                                                     \</span>
<a name="l00367"></a>00367 <span class="preprocessor">  for(_ho_i=0; _ho_i &lt; keylen; _ho_i++) {                                        \</span>
<a name="l00368"></a>00368 <span class="preprocessor">      hashv += _ho_key[_ho_i];                                                   \</span>
<a name="l00369"></a>00369 <span class="preprocessor">      hashv += (hashv &lt;&lt; 10);                                                    \</span>
<a name="l00370"></a>00370 <span class="preprocessor">      hashv ^= (hashv &gt;&gt; 6);                                                     \</span>
<a name="l00371"></a>00371 <span class="preprocessor">  }                                                                              \</span>
<a name="l00372"></a>00372 <span class="preprocessor">  hashv += (hashv &lt;&lt; 3);                                                         \</span>
<a name="l00373"></a>00373 <span class="preprocessor">  hashv ^= (hashv &gt;&gt; 11);                                                        \</span>
<a name="l00374"></a>00374 <span class="preprocessor">  hashv += (hashv &lt;&lt; 15);                                                        \</span>
<a name="l00375"></a>00375 <span class="preprocessor">  bkt = hashv &amp; (num_bkts-1);                                                    \</span>
<a name="l00376"></a>00376 <span class="preprocessor">} while(0)</span>
<a name="l00377"></a>00377 <span class="preprocessor"></span>
<a name="l00378"></a><a class="code" href="uthash_8h.html#a6d37144e54d2bd49eb88fbfd04c59dc5">00378</a> <span class="preprocessor">#define HASH_JEN_MIX(a,b,c)                                                      \</span>
<a name="l00379"></a>00379 <span class="preprocessor">do {                                                                             \</span>
<a name="l00380"></a>00380 <span class="preprocessor">  a -= b; a -= c; a ^= ( c &gt;&gt; 13 );                                              \</span>
<a name="l00381"></a>00381 <span class="preprocessor">  b -= c; b -= a; b ^= ( a &lt;&lt; 8 );                                               \</span>
<a name="l00382"></a>00382 <span class="preprocessor">  c -= a; c -= b; c ^= ( b &gt;&gt; 13 );                                              \</span>
<a name="l00383"></a>00383 <span class="preprocessor">  a -= b; a -= c; a ^= ( c &gt;&gt; 12 );                                              \</span>
<a name="l00384"></a>00384 <span class="preprocessor">  b -= c; b -= a; b ^= ( a &lt;&lt; 16 );                                              \</span>
<a name="l00385"></a>00385 <span class="preprocessor">  c -= a; c -= b; c ^= ( b &gt;&gt; 5 );                                               \</span>
<a name="l00386"></a>00386 <span class="preprocessor">  a -= b; a -= c; a ^= ( c &gt;&gt; 3 );                                               \</span>
<a name="l00387"></a>00387 <span class="preprocessor">  b -= c; b -= a; b ^= ( a &lt;&lt; 10 );                                              \</span>
<a name="l00388"></a>00388 <span class="preprocessor">  c -= a; c -= b; c ^= ( b &gt;&gt; 15 );                                              \</span>
<a name="l00389"></a>00389 <span class="preprocessor">} while (0)</span>
<a name="l00390"></a>00390 <span class="preprocessor"></span>
<a name="l00391"></a><a class="code" href="uthash_8h.html#aa16e3ae6125d7f10d3deb4695e0ee51e">00391</a> <span class="preprocessor">#define HASH_JEN(key,keylen,num_bkts,hashv,bkt)                                  \</span>
<a name="l00392"></a>00392 <span class="preprocessor">do {                                                                             \</span>
<a name="l00393"></a>00393 <span class="preprocessor">  unsigned _hj_i,_hj_j,_hj_k;                                                    \</span>
<a name="l00394"></a>00394 <span class="preprocessor">  char *_hj_key=(char*)(key);                                                    \</span>
<a name="l00395"></a>00395 <span class="preprocessor">  hashv = 0xfeedbeef;                                                            \</span>
<a name="l00396"></a>00396 <span class="preprocessor">  _hj_i = _hj_j = 0x9e3779b9;                                                    \</span>
<a name="l00397"></a>00397 <span class="preprocessor">  _hj_k = keylen;                                                                \</span>
<a name="l00398"></a>00398 <span class="preprocessor">  while (_hj_k &gt;= 12) {                                                          \</span>
<a name="l00399"></a>00399 <span class="preprocessor">    _hj_i +=    (_hj_key[0] + ( (unsigned)_hj_key[1] &lt;&lt; 8 )                      \</span>
<a name="l00400"></a>00400 <span class="preprocessor">        + ( (unsigned)_hj_key[2] &lt;&lt; 16 )                                         \</span>
<a name="l00401"></a>00401 <span class="preprocessor">        + ( (unsigned)_hj_key[3] &lt;&lt; 24 ) );                                      \</span>
<a name="l00402"></a>00402 <span class="preprocessor">    _hj_j +=    (_hj_key[4] + ( (unsigned)_hj_key[5] &lt;&lt; 8 )                      \</span>
<a name="l00403"></a>00403 <span class="preprocessor">        + ( (unsigned)_hj_key[6] &lt;&lt; 16 )                                         \</span>
<a name="l00404"></a>00404 <span class="preprocessor">        + ( (unsigned)_hj_key[7] &lt;&lt; 24 ) );                                      \</span>
<a name="l00405"></a>00405 <span class="preprocessor">    hashv += (_hj_key[8] + ( (unsigned)_hj_key[9] &lt;&lt; 8 )                         \</span>
<a name="l00406"></a>00406 <span class="preprocessor">        + ( (unsigned)_hj_key[10] &lt;&lt; 16 )                                        \</span>
<a name="l00407"></a>00407 <span class="preprocessor">        + ( (unsigned)_hj_key[11] &lt;&lt; 24 ) );                                     \</span>
<a name="l00408"></a>00408 <span class="preprocessor">                                                                                 \</span>
<a name="l00409"></a>00409 <span class="preprocessor">     HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                          \</span>
<a name="l00410"></a>00410 <span class="preprocessor">                                                                                 \</span>
<a name="l00411"></a>00411 <span class="preprocessor">     _hj_key += 12;                                                              \</span>
<a name="l00412"></a>00412 <span class="preprocessor">     _hj_k -= 12;                                                                \</span>
<a name="l00413"></a>00413 <span class="preprocessor">  }                                                                              \</span>
<a name="l00414"></a>00414 <span class="preprocessor">  hashv += keylen;                                                               \</span>
<a name="l00415"></a>00415 <span class="preprocessor">  switch ( _hj_k ) {                                                             \</span>
<a name="l00416"></a>00416 <span class="preprocessor">     case 11: hashv += ( (unsigned)_hj_key[10] &lt;&lt; 24 );                          \</span>
<a name="l00417"></a>00417 <span class="preprocessor">     case 10: hashv += ( (unsigned)_hj_key[9] &lt;&lt; 16 );                           \</span>
<a name="l00418"></a>00418 <span class="preprocessor">     case 9:  hashv += ( (unsigned)_hj_key[8] &lt;&lt; 8 );                            \</span>
<a name="l00419"></a>00419 <span class="preprocessor">     case 8:  _hj_j += ( (unsigned)_hj_key[7] &lt;&lt; 24 );                           \</span>
<a name="l00420"></a>00420 <span class="preprocessor">     case 7:  _hj_j += ( (unsigned)_hj_key[6] &lt;&lt; 16 );                           \</span>
<a name="l00421"></a>00421 <span class="preprocessor">     case 6:  _hj_j += ( (unsigned)_hj_key[5] &lt;&lt; 8 );                            \</span>
<a name="l00422"></a>00422 <span class="preprocessor">     case 5:  _hj_j += _hj_key[4];                                               \</span>
<a name="l00423"></a>00423 <span class="preprocessor">     case 4:  _hj_i += ( (unsigned)_hj_key[3] &lt;&lt; 24 );                           \</span>
<a name="l00424"></a>00424 <span class="preprocessor">     case 3:  _hj_i += ( (unsigned)_hj_key[2] &lt;&lt; 16 );                           \</span>
<a name="l00425"></a>00425 <span class="preprocessor">     case 2:  _hj_i += ( (unsigned)_hj_key[1] &lt;&lt; 8 );                            \</span>
<a name="l00426"></a>00426 <span class="preprocessor">     case 1:  _hj_i += _hj_key[0];                                               \</span>
<a name="l00427"></a>00427 <span class="preprocessor">  }                                                                              \</span>
<a name="l00428"></a>00428 <span class="preprocessor">  HASH_JEN_MIX(_hj_i, _hj_j, hashv);                                             \</span>
<a name="l00429"></a>00429 <span class="preprocessor">  bkt = hashv &amp; (num_bkts-1);                                                    \</span>
<a name="l00430"></a>00430 <span class="preprocessor">} while(0)</span>
<a name="l00431"></a>00431 <span class="preprocessor"></span>
<a name="l00432"></a>00432 <span class="comment">/* The Paul Hsieh hash function */</span>
<a name="l00433"></a>00433 <span class="preprocessor">#undef get16bits</span>
<a name="l00434"></a>00434 <span class="preprocessor"></span><span class="preprocessor">#if (defined(__GNUC__) &amp;&amp; defined(__i386__)) || defined(__WATCOMC__)             \</span>
<a name="l00435"></a>00435 <span class="preprocessor">  || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__)</span>
<a name="l00436"></a>00436 <span class="preprocessor"></span><span class="preprocessor">#define get16bits(d) (*((const uint16_t *) (d)))</span>
<a name="l00437"></a>00437 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00438"></a>00438 <span class="preprocessor"></span>
<a name="l00439"></a>00439 <span class="preprocessor">#if !defined (get16bits)</span>
<a name="l00440"></a><a class="code" href="uthash_8h.html#abc7d71657be8975a51684e41029b7964">00440</a> <span class="preprocessor"></span><span class="preprocessor">#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) &lt;&lt; 8)             \</span>
<a name="l00441"></a>00441 <span class="preprocessor">                       +(uint32_t)(((const uint8_t *)(d))[0]) )</span>
<a name="l00442"></a>00442 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00443"></a><a class="code" href="uthash_8h.html#ab595698a74642684dace0dfa47dab445">00443</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_SFH(key,keylen,num_bkts,hashv,bkt)                                  \</span>
<a name="l00444"></a>00444 <span class="preprocessor">do {                                                                             \</span>
<a name="l00445"></a>00445 <span class="preprocessor">  char *_sfh_key=(char*)(key);                                                   \</span>
<a name="l00446"></a>00446 <span class="preprocessor">  uint32_t _sfh_tmp, _sfh_len = keylen;                                          \</span>
<a name="l00447"></a>00447 <span class="preprocessor">                                                                                 \</span>
<a name="l00448"></a>00448 <span class="preprocessor">  int _sfh_rem = _sfh_len &amp; 3;                                                   \</span>
<a name="l00449"></a>00449 <span class="preprocessor">  _sfh_len &gt;&gt;= 2;                                                                \</span>
<a name="l00450"></a>00450 <span class="preprocessor">  hashv = 0xcafebabe;                                                            \</span>
<a name="l00451"></a>00451 <span class="preprocessor">                                                                                 \</span>
<a name="l00452"></a>00452 <span class="preprocessor">  </span><span class="comment">/* Main loop */</span>                                                                \
<a name="l00453"></a>00453   for (;_sfh_len &gt; 0; _sfh_len--) {                                              \
<a name="l00454"></a>00454     hashv    += get16bits (_sfh_key);                                            \
<a name="l00455"></a>00455     _sfh_tmp       = (get16bits (_sfh_key+2) &lt;&lt; 11) ^ hashv;                     \
<a name="l00456"></a>00456     hashv     = (hashv &lt;&lt; 16) ^ _sfh_tmp;                                        \
<a name="l00457"></a>00457     _sfh_key += 2*sizeof (uint16_t);                                             \
<a name="l00458"></a>00458     hashv    += hashv &gt;&gt; 11;                                                     \
<a name="l00459"></a>00459   }                                                                              \
<a name="l00460"></a>00460                                                                                  \
<a name="l00461"></a>00461   <span class="comment">/* Handle end cases */</span>                                                         \
<a name="l00462"></a>00462   switch (_sfh_rem) {                                                            \
<a name="l00463"></a>00463     case 3: hashv += get16bits (_sfh_key);                                       \
<a name="l00464"></a>00464             hashv ^= hashv &lt;&lt; 16;                                                \
<a name="l00465"></a>00465             hashv ^= _sfh_key[sizeof (uint16_t)] &lt;&lt; 18;                          \
<a name="l00466"></a>00466             hashv += hashv &gt;&gt; 11;                                                \
<a name="l00467"></a>00467             break;                                                               \
<a name="l00468"></a>00468     case 2: hashv += get16bits (_sfh_key);                                       \
<a name="l00469"></a>00469             hashv ^= hashv &lt;&lt; 11;                                                \
<a name="l00470"></a>00470             hashv += hashv &gt;&gt; 17;                                                \
<a name="l00471"></a>00471             break;                                                               \
<a name="l00472"></a>00472     case 1: hashv += *_sfh_key;                                                  \
<a name="l00473"></a>00473             hashv ^= hashv &lt;&lt; 10;                                                \
<a name="l00474"></a>00474             hashv += hashv &gt;&gt; 1;                                                 \
<a name="l00475"></a>00475   }                                                                              \
<a name="l00476"></a>00476                                                                                  \
<a name="l00477"></a>00477     <span class="comment">/* Force &quot;avalanching&quot; of final 127 bits */</span>                                  \
<a name="l00478"></a>00478     hashv ^= hashv &lt;&lt; 3;                                                         \
<a name="l00479"></a>00479     hashv += hashv &gt;&gt; 5;                                                         \
<a name="l00480"></a>00480     hashv ^= hashv &lt;&lt; 4;                                                         \
<a name="l00481"></a>00481     hashv += hashv &gt;&gt; 17;                                                        \
<a name="l00482"></a>00482     hashv ^= hashv &lt;&lt; 25;                                                        \
<a name="l00483"></a>00483     hashv += hashv &gt;&gt; 6;                                                         \
<a name="l00484"></a>00484     bkt = hashv &amp; (num_bkts-1);                                                  \
<a name="l00485"></a>00485 } while(0);
<a name="l00486"></a>00486 
<a name="l00487"></a>00487 <span class="preprocessor">#ifdef HASH_USING_NO_STRICT_ALIASING</span>
<a name="l00488"></a>00488 <span class="preprocessor"></span><span class="comment">/* The MurmurHash exploits some CPU&#39;s (e.g. x86) tolerance for unaligned reads.</span>
<a name="l00489"></a>00489 <span class="comment"> * For other types of CPU&#39;s (e.g. Sparc) an unaligned read causes a bus error.</span>
<a name="l00490"></a>00490 <span class="comment"> * So MurmurHash comes in two versions, the faster unaligned one and the slower</span>
<a name="l00491"></a>00491 <span class="comment"> * aligned one. We only use the faster one on CPU&#39;s where we know it&#39;s safe. </span>
<a name="l00492"></a>00492 <span class="comment"> *</span>
<a name="l00493"></a>00493 <span class="comment"> * Note the preprocessor built-in defines can be emitted using:</span>
<a name="l00494"></a>00494 <span class="comment"> *</span>
<a name="l00495"></a>00495 <span class="comment"> *   gcc -m64 -dM -E - &lt; /dev/null                  (on gcc)</span>
<a name="l00496"></a>00496 <span class="comment"> *   cc -## a.c (where a.c is a simple test file)   (Sun Studio)</span>
<a name="l00497"></a>00497 <span class="comment"> */</span>
<a name="l00498"></a>00498 <span class="preprocessor">#if (defined(__i386__) || defined(__x86_64__)) </span>
<a name="l00499"></a>00499 <span class="preprocessor"></span><span class="preprocessor">#define HASH_MUR HASH_MUR_UNALIGNED</span>
<a name="l00500"></a>00500 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00501"></a>00501 <span class="preprocessor"></span><span class="preprocessor">#define HASH_MUR HASH_MUR_ALIGNED</span>
<a name="l00502"></a>00502 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00503"></a>00503 <span class="preprocessor"></span>
<a name="l00504"></a>00504 <span class="comment">/* Appleby&#39;s MurmurHash fast version for unaligned-tolerant archs like i386 */</span>
<a name="l00505"></a>00505 <span class="preprocessor">#define HASH_MUR_UNALIGNED(key,keylen,num_bkts,hashv,bkt)                        \</span>
<a name="l00506"></a>00506 <span class="preprocessor">do {                                                                             \</span>
<a name="l00507"></a>00507 <span class="preprocessor">  const unsigned int _mur_m = 0x5bd1e995;                                        \</span>
<a name="l00508"></a>00508 <span class="preprocessor">  const int _mur_r = 24;                                                         \</span>
<a name="l00509"></a>00509 <span class="preprocessor">  hashv = 0xcafebabe ^ keylen;                                                   \</span>
<a name="l00510"></a>00510 <span class="preprocessor">  char *_mur_key = (char *)(key);                                                \</span>
<a name="l00511"></a>00511 <span class="preprocessor">  uint32_t _mur_tmp, _mur_len = keylen;                                          \</span>
<a name="l00512"></a>00512 <span class="preprocessor">                                                                                 \</span>
<a name="l00513"></a>00513 <span class="preprocessor">  for (;_mur_len &gt;= 4; _mur_len-=4) {                                            \</span>
<a name="l00514"></a>00514 <span class="preprocessor">    _mur_tmp = *(uint32_t *)_mur_key;                                            \</span>
<a name="l00515"></a>00515 <span class="preprocessor">    _mur_tmp *= _mur_m;                                                          \</span>
<a name="l00516"></a>00516 <span class="preprocessor">    _mur_tmp ^= _mur_tmp &gt;&gt; _mur_r;                                              \</span>
<a name="l00517"></a>00517 <span class="preprocessor">    _mur_tmp *= _mur_m;                                                          \</span>
<a name="l00518"></a>00518 <span class="preprocessor">    hashv *= _mur_m;                                                             \</span>
<a name="l00519"></a>00519 <span class="preprocessor">    hashv ^= _mur_tmp;                                                           \</span>
<a name="l00520"></a>00520 <span class="preprocessor">    _mur_key += 4;                                                               \</span>
<a name="l00521"></a>00521 <span class="preprocessor">  }                                                                              \</span>
<a name="l00522"></a>00522 <span class="preprocessor">                                                                                 \</span>
<a name="l00523"></a>00523 <span class="preprocessor">  switch(_mur_len)                                                               \</span>
<a name="l00524"></a>00524 <span class="preprocessor">  {                                                                              \</span>
<a name="l00525"></a>00525 <span class="preprocessor">    case 3: hashv ^= _mur_key[2] &lt;&lt; 16;                                          \</span>
<a name="l00526"></a>00526 <span class="preprocessor">    case 2: hashv ^= _mur_key[1] &lt;&lt; 8;                                           \</span>
<a name="l00527"></a>00527 <span class="preprocessor">    case 1: hashv ^= _mur_key[0];                                                \</span>
<a name="l00528"></a>00528 <span class="preprocessor">            hashv *= _mur_m;                                                     \</span>
<a name="l00529"></a>00529 <span class="preprocessor">  };                                                                             \</span>
<a name="l00530"></a>00530 <span class="preprocessor">                                                                                 \</span>
<a name="l00531"></a>00531 <span class="preprocessor">  hashv ^= hashv &gt;&gt; 13;                                                          \</span>
<a name="l00532"></a>00532 <span class="preprocessor">  hashv *= _mur_m;                                                               \</span>
<a name="l00533"></a>00533 <span class="preprocessor">  hashv ^= hashv &gt;&gt; 15;                                                          \</span>
<a name="l00534"></a>00534 <span class="preprocessor">                                                                                 \</span>
<a name="l00535"></a>00535 <span class="preprocessor">  bkt = hashv &amp; (num_bkts-1);                                                    \</span>
<a name="l00536"></a>00536 <span class="preprocessor">} while(0)</span>
<a name="l00537"></a>00537 <span class="preprocessor"></span>
<a name="l00538"></a>00538 <span class="comment">/* Appleby&#39;s MurmurHash version for alignment-sensitive archs like Sparc */</span>
<a name="l00539"></a>00539 <span class="preprocessor">#define HASH_MUR_ALIGNED(key,keylen,num_bkts,hashv,bkt)                          \</span>
<a name="l00540"></a>00540 <span class="preprocessor">do {                                                                             \</span>
<a name="l00541"></a>00541 <span class="preprocessor">  const unsigned int _mur_m = 0x5bd1e995;                                        \</span>
<a name="l00542"></a>00542 <span class="preprocessor">  const int _mur_r = 24;                                                         \</span>
<a name="l00543"></a>00543 <span class="preprocessor">  hashv = 0xcafebabe ^ (keylen);                                                 \</span>
<a name="l00544"></a>00544 <span class="preprocessor">  char *_mur_key = (char *)(key);                                                \</span>
<a name="l00545"></a>00545 <span class="preprocessor">  uint32_t _mur_len = keylen;                                                    \</span>
<a name="l00546"></a>00546 <span class="preprocessor">  int _mur_align = (int)_mur_key &amp; 3;                                            \</span>
<a name="l00547"></a>00547 <span class="preprocessor">                                                                                 \</span>
<a name="l00548"></a>00548 <span class="preprocessor">  if (_mur_align &amp;&amp; (_mur_len &gt;= 4)) {                                           \</span>
<a name="l00549"></a>00549 <span class="preprocessor">    unsigned _mur_t = 0, _mur_d = 0;                                             \</span>
<a name="l00550"></a>00550 <span class="preprocessor">    switch(_mur_align) {                                                         \</span>
<a name="l00551"></a>00551 <span class="preprocessor">      case 1: _mur_t |= _mur_key[2] &lt;&lt; 16;                                       \</span>
<a name="l00552"></a>00552 <span class="preprocessor">      case 2: _mur_t |= _mur_key[1] &lt;&lt; 8;                                        \</span>
<a name="l00553"></a>00553 <span class="preprocessor">      case 3: _mur_t |= _mur_key[0];                                             \</span>
<a name="l00554"></a>00554 <span class="preprocessor">    }                                                                            \</span>
<a name="l00555"></a>00555 <span class="preprocessor">    _mur_t &lt;&lt;= (8 * _mur_align);                                                 \</span>
<a name="l00556"></a>00556 <span class="preprocessor">    _mur_key += 4-_mur_align;                                                    \</span>
<a name="l00557"></a>00557 <span class="preprocessor">    _mur_len -= 4-_mur_align;                                                    \</span>
<a name="l00558"></a>00558 <span class="preprocessor">    int _mur_sl = 8 * (4-_mur_align);                                            \</span>
<a name="l00559"></a>00559 <span class="preprocessor">    int _mur_sr = 8 * _mur_align;                                                \</span>
<a name="l00560"></a>00560 <span class="preprocessor">                                                                                 \</span>
<a name="l00561"></a>00561 <span class="preprocessor">    for (;_mur_len &gt;= 4; _mur_len-=4) {                                          \</span>
<a name="l00562"></a>00562 <span class="preprocessor">      _mur_d = *(unsigned *)_mur_key;                                            \</span>
<a name="l00563"></a>00563 <span class="preprocessor">      _mur_t = (_mur_t &gt;&gt; _mur_sr) | (_mur_d &lt;&lt; _mur_sl);                        \</span>
<a name="l00564"></a>00564 <span class="preprocessor">      unsigned _mur_k = _mur_t;                                                  \</span>
<a name="l00565"></a>00565 <span class="preprocessor">      _mur_k *= _mur_m;                                                          \</span>
<a name="l00566"></a>00566 <span class="preprocessor">      _mur_k ^= _mur_k &gt;&gt; _mur_r;                                                \</span>
<a name="l00567"></a>00567 <span class="preprocessor">      _mur_k *= _mur_m;                                                          \</span>
<a name="l00568"></a>00568 <span class="preprocessor">      hashv *= _mur_m;                                                           \</span>
<a name="l00569"></a>00569 <span class="preprocessor">      hashv ^= _mur_k;                                                           \</span>
<a name="l00570"></a>00570 <span class="preprocessor">      _mur_t = _mur_d;                                                           \</span>
<a name="l00571"></a>00571 <span class="preprocessor">      _mur_key += 4;                                                             \</span>
<a name="l00572"></a>00572 <span class="preprocessor">    }                                                                            \</span>
<a name="l00573"></a>00573 <span class="preprocessor">    _mur_d = 0;                                                                  \</span>
<a name="l00574"></a>00574 <span class="preprocessor">    if(_mur_len &gt;= _mur_align) {                                                 \</span>
<a name="l00575"></a>00575 <span class="preprocessor">      switch(_mur_align) {                                                       \</span>
<a name="l00576"></a>00576 <span class="preprocessor">        case 3: _mur_d |= _mur_key[2] &lt;&lt; 16;                                     \</span>
<a name="l00577"></a>00577 <span class="preprocessor">        case 2: _mur_d |= _mur_key[1] &lt;&lt; 8;                                      \</span>
<a name="l00578"></a>00578 <span class="preprocessor">        case 1: _mur_d |= _mur_key[0];                                           \</span>
<a name="l00579"></a>00579 <span class="preprocessor">      }                                                                          \</span>
<a name="l00580"></a>00580 <span class="preprocessor">      unsigned _mur_k = (_mur_t &gt;&gt; _mur_sr) | (_mur_d &lt;&lt; _mur_sl);               \</span>
<a name="l00581"></a>00581 <span class="preprocessor">      _mur_k *= _mur_m;                                                          \</span>
<a name="l00582"></a>00582 <span class="preprocessor">      _mur_k ^= _mur_k &gt;&gt; _mur_r;                                                \</span>
<a name="l00583"></a>00583 <span class="preprocessor">      _mur_k *= _mur_m;                                                          \</span>
<a name="l00584"></a>00584 <span class="preprocessor">      hashv *= _mur_m;                                                           \</span>
<a name="l00585"></a>00585 <span class="preprocessor">      hashv ^= _mur_k;                                                           \</span>
<a name="l00586"></a>00586 <span class="preprocessor">      _mur_k += _mur_align;                                                      \</span>
<a name="l00587"></a>00587 <span class="preprocessor">      _mur_len -= _mur_align;                                                    \</span>
<a name="l00588"></a>00588 <span class="preprocessor">                                                                                 \</span>
<a name="l00589"></a>00589 <span class="preprocessor">      switch(_mur_len)                                                           \</span>
<a name="l00590"></a>00590 <span class="preprocessor">      {                                                                          \</span>
<a name="l00591"></a>00591 <span class="preprocessor">        case 3: hashv ^= _mur_key[2] &lt;&lt; 16;                                      \</span>
<a name="l00592"></a>00592 <span class="preprocessor">        case 2: hashv ^= _mur_key[1] &lt;&lt; 8;                                       \</span>
<a name="l00593"></a>00593 <span class="preprocessor">        case 1: hashv ^= _mur_key[0];                                            \</span>
<a name="l00594"></a>00594 <span class="preprocessor">                hashv *= _mur_m;                                                 \</span>
<a name="l00595"></a>00595 <span class="preprocessor">      }                                                                          \</span>
<a name="l00596"></a>00596 <span class="preprocessor">    } else {                                                                     \</span>
<a name="l00597"></a>00597 <span class="preprocessor">      switch(_mur_len)                                                           \</span>
<a name="l00598"></a>00598 <span class="preprocessor">      {                                                                          \</span>
<a name="l00599"></a>00599 <span class="preprocessor">        case 3: _mur_d ^= _mur_key[2] &lt;&lt; 16;                                     \</span>
<a name="l00600"></a>00600 <span class="preprocessor">        case 2: _mur_d ^= _mur_key[1] &lt;&lt; 8;                                      \</span>
<a name="l00601"></a>00601 <span class="preprocessor">        case 1: _mur_d ^= _mur_key[0];                                           \</span>
<a name="l00602"></a>00602 <span class="preprocessor">        case 0: hashv ^= (_mur_t &gt;&gt; _mur_sr) | (_mur_d &lt;&lt; _mur_sl);              \</span>
<a name="l00603"></a>00603 <span class="preprocessor">        hashv *= _mur_m;                                                         \</span>
<a name="l00604"></a>00604 <span class="preprocessor">      }                                                                          \</span>
<a name="l00605"></a>00605 <span class="preprocessor">    }                                                                            \</span>
<a name="l00606"></a>00606 <span class="preprocessor">                                                                                 \</span>
<a name="l00607"></a>00607 <span class="preprocessor">    hashv ^= hashv &gt;&gt; 13;                                                        \</span>
<a name="l00608"></a>00608 <span class="preprocessor">    hashv *= _mur_m;                                                             \</span>
<a name="l00609"></a>00609 <span class="preprocessor">    hashv ^= hashv &gt;&gt; 15;                                                        \</span>
<a name="l00610"></a>00610 <span class="preprocessor">  } else {                                                                       \</span>
<a name="l00611"></a>00611 <span class="preprocessor">    for (;_mur_len &gt;= 4; _mur_len-=4) {                                          \</span>
<a name="l00612"></a>00612 <span class="preprocessor">      unsigned _mur_k = *(unsigned*)_mur_key;                                    \</span>
<a name="l00613"></a>00613 <span class="preprocessor">      _mur_k *= _mur_m;                                                          \</span>
<a name="l00614"></a>00614 <span class="preprocessor">      _mur_k ^= _mur_k &gt;&gt; _mur_r;                                                \</span>
<a name="l00615"></a>00615 <span class="preprocessor">      _mur_k *= _mur_m;                                                          \</span>
<a name="l00616"></a>00616 <span class="preprocessor">      hashv *= _mur_m;                                                           \</span>
<a name="l00617"></a>00617 <span class="preprocessor">      hashv ^= _mur_k;                                                           \</span>
<a name="l00618"></a>00618 <span class="preprocessor">      _mur_key += 4;                                                             \</span>
<a name="l00619"></a>00619 <span class="preprocessor">    }                                                                            \</span>
<a name="l00620"></a>00620 <span class="preprocessor">    switch(_mur_len)                                                             \</span>
<a name="l00621"></a>00621 <span class="preprocessor">    {                                                                            \</span>
<a name="l00622"></a>00622 <span class="preprocessor">      case 3: hashv ^= _mur_key[2] &lt;&lt; 16;                                        \</span>
<a name="l00623"></a>00623 <span class="preprocessor">      case 2: hashv ^= _mur_key[1] &lt;&lt; 8;                                         \</span>
<a name="l00624"></a>00624 <span class="preprocessor">      case 1: hashv ^= _mur_key[0];                                              \</span>
<a name="l00625"></a>00625 <span class="preprocessor">      hashv *= _mur_m;                                                           \</span>
<a name="l00626"></a>00626 <span class="preprocessor">    }                                                                            \</span>
<a name="l00627"></a>00627 <span class="preprocessor">                                                                                 \</span>
<a name="l00628"></a>00628 <span class="preprocessor">    hashv ^= hashv &gt;&gt; 13;                                                        \</span>
<a name="l00629"></a>00629 <span class="preprocessor">    hashv *= _mur_m;                                                             \</span>
<a name="l00630"></a>00630 <span class="preprocessor">    hashv ^= hashv &gt;&gt; 15;                                                        \</span>
<a name="l00631"></a>00631 <span class="preprocessor">  }                                                                              \</span>
<a name="l00632"></a>00632 <span class="preprocessor">  bkt = hashv &amp; (num_bkts-1);                                                    \</span>
<a name="l00633"></a>00633 <span class="preprocessor">} while(0)</span>
<a name="l00634"></a>00634 <span class="preprocessor"></span><span class="preprocessor">#endif  </span><span class="comment">/* HASH_USING_NO_STRICT_ALIASING */</span>
<a name="l00635"></a>00635 
<a name="l00636"></a>00636 <span class="comment">/* key comparison function; return 0 if keys equal */</span>
<a name="l00637"></a><a class="code" href="uthash_8h.html#a35c9b682ebb7a8cbf284b9f0a9594095">00637</a> <span class="preprocessor">#define HASH_KEYCMP(a,b,len) memcmp(a,b,len) </span>
<a name="l00638"></a>00638 <span class="preprocessor"></span>
<a name="l00639"></a>00639 <span class="comment">/* iterate over items in a known bucket to find desired item */</span>
<a name="l00640"></a><a class="code" href="uthash_8h.html#a42ae87cc63106a82601808f19329502c">00640</a> <span class="preprocessor">#define HASH_FIND_IN_BKT(tbl,hh,head,keyptr,keylen_in,out)                       \</span>
<a name="l00641"></a>00641 <span class="preprocessor">do {                                                                             \</span>
<a name="l00642"></a>00642 <span class="preprocessor"> if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head));          \</span>
<a name="l00643"></a>00643 <span class="preprocessor"> else out=NULL;                                                                  \</span>
<a name="l00644"></a>00644 <span class="preprocessor"> while (out) {                                                                   \</span>
<a name="l00645"></a>00645 <span class="preprocessor">    if (out-&gt;hh.keylen == keylen_in) {                                           \</span>
<a name="l00646"></a>00646 <span class="preprocessor">        if ((HASH_KEYCMP(out-&gt;hh.key,keyptr,keylen_in)) == 0) break;             \</span>
<a name="l00647"></a>00647 <span class="preprocessor">    }                                                                            \</span>
<a name="l00648"></a>00648 <span class="preprocessor">    if (out-&gt;hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,out-&gt;hh.hh_next)); \</span>
<a name="l00649"></a>00649 <span class="preprocessor">    else out = NULL;                                                             \</span>
<a name="l00650"></a>00650 <span class="preprocessor"> }                                                                               \</span>
<a name="l00651"></a>00651 <span class="preprocessor">} while(0)</span>
<a name="l00652"></a>00652 <span class="preprocessor"></span>
<a name="l00653"></a>00653 <span class="comment">/* add an item to a bucket  */</span>
<a name="l00654"></a><a class="code" href="uthash_8h.html#a78e11adee321f45c5cb31ff2d6eb0348">00654</a> <span class="preprocessor">#define HASH_ADD_TO_BKT(head,addhh)                                              \</span>
<a name="l00655"></a>00655 <span class="preprocessor">do {                                                                             \</span>
<a name="l00656"></a>00656 <span class="preprocessor"> head.count++;                                                                   \</span>
<a name="l00657"></a>00657 <span class="preprocessor"> (addhh)-&gt;hh_next = head.hh_head;                                                \</span>
<a name="l00658"></a>00658 <span class="preprocessor"> (addhh)-&gt;hh_prev = NULL;                                                        \</span>
<a name="l00659"></a>00659 <span class="preprocessor"> if (head.hh_head) { (head).hh_head-&gt;hh_prev = (addhh); }                        \</span>
<a name="l00660"></a>00660 <span class="preprocessor"> (head).hh_head=addhh;                                                           \</span>
<a name="l00661"></a>00661 <span class="preprocessor"> if (head.count &gt;= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH)             \</span>
<a name="l00662"></a>00662 <span class="preprocessor">     &amp;&amp; (addhh)-&gt;tbl-&gt;noexpand != 1) {                                           \</span>
<a name="l00663"></a>00663 <span class="preprocessor">       HASH_EXPAND_BUCKETS((addhh)-&gt;tbl);                                        \</span>
<a name="l00664"></a>00664 <span class="preprocessor"> }                                                                               \</span>
<a name="l00665"></a>00665 <span class="preprocessor">} while(0)</span>
<a name="l00666"></a>00666 <span class="preprocessor"></span>
<a name="l00667"></a>00667 <span class="comment">/* remove an item from a given bucket */</span>
<a name="l00668"></a><a class="code" href="uthash_8h.html#a1b2d6f694f98cf6350cdd18225cb3f78">00668</a> <span class="preprocessor">#define HASH_DEL_IN_BKT(hh,head,hh_del)                                          \</span>
<a name="l00669"></a>00669 <span class="preprocessor">    (head).count--;                                                              \</span>
<a name="l00670"></a>00670 <span class="preprocessor">    if ((head).hh_head == hh_del) {                                              \</span>
<a name="l00671"></a>00671 <span class="preprocessor">      (head).hh_head = hh_del-&gt;hh_next;                                          \</span>
<a name="l00672"></a>00672 <span class="preprocessor">    }                                                                            \</span>
<a name="l00673"></a>00673 <span class="preprocessor">    if (hh_del-&gt;hh_prev) {                                                       \</span>
<a name="l00674"></a>00674 <span class="preprocessor">        hh_del-&gt;hh_prev-&gt;hh_next = hh_del-&gt;hh_next;                              \</span>
<a name="l00675"></a>00675 <span class="preprocessor">    }                                                                            \</span>
<a name="l00676"></a>00676 <span class="preprocessor">    if (hh_del-&gt;hh_next) {                                                       \</span>
<a name="l00677"></a>00677 <span class="preprocessor">        hh_del-&gt;hh_next-&gt;hh_prev = hh_del-&gt;hh_prev;                              \</span>
<a name="l00678"></a>00678 <span class="preprocessor">    }                                                                </span>
<a name="l00679"></a>00679 <span class="preprocessor"></span>
<a name="l00680"></a>00680 <span class="comment">/* Bucket expansion has the effect of doubling the number of buckets</span>
<a name="l00681"></a>00681 <span class="comment"> * and redistributing the items into the new buckets. Ideally the</span>
<a name="l00682"></a>00682 <span class="comment"> * items will distribute more or less evenly into the new buckets</span>
<a name="l00683"></a>00683 <span class="comment"> * (the extent to which this is true is a measure of the quality of</span>
<a name="l00684"></a>00684 <span class="comment"> * the hash function as it applies to the key domain). </span>
<a name="l00685"></a>00685 <span class="comment"> * </span>
<a name="l00686"></a>00686 <span class="comment"> * With the items distributed into more buckets, the chain length</span>
<a name="l00687"></a>00687 <span class="comment"> * (item count) in each bucket is reduced. Thus by expanding buckets</span>
<a name="l00688"></a>00688 <span class="comment"> * the hash keeps a bound on the chain length. This bounded chain </span>
<a name="l00689"></a>00689 <span class="comment"> * length is the essence of how a hash provides constant time lookup.</span>
<a name="l00690"></a>00690 <span class="comment"> * </span>
<a name="l00691"></a>00691 <span class="comment"> * The calculation of tbl-&gt;ideal_chain_maxlen below deserves some</span>
<a name="l00692"></a>00692 <span class="comment"> * explanation. First, keep in mind that we&#39;re calculating the ideal</span>
<a name="l00693"></a>00693 <span class="comment"> * maximum chain length based on the *new* (doubled) bucket count.</span>
<a name="l00694"></a>00694 <span class="comment"> * In fractions this is just n/b (n=number of items,b=new num buckets).</span>
<a name="l00695"></a>00695 <span class="comment"> * Since the ideal chain length is an integer, we want to calculate </span>
<a name="l00696"></a>00696 <span class="comment"> * ceil(n/b). We don&#39;t depend on floating point arithmetic in this</span>
<a name="l00697"></a>00697 <span class="comment"> * hash, so to calculate ceil(n/b) with integers we could write</span>
<a name="l00698"></a>00698 <span class="comment"> * </span>
<a name="l00699"></a>00699 <span class="comment"> *      ceil(n/b) = (n/b) + ((n%b)?1:0)</span>
<a name="l00700"></a>00700 <span class="comment"> * </span>
<a name="l00701"></a>00701 <span class="comment"> * and in fact a previous version of this hash did just that.</span>
<a name="l00702"></a>00702 <span class="comment"> * But now we have improved things a bit by recognizing that b is</span>
<a name="l00703"></a>00703 <span class="comment"> * always a power of two. We keep its base 2 log handy (call it lb),</span>
<a name="l00704"></a>00704 <span class="comment"> * so now we can write this with a bit shift and logical AND:</span>
<a name="l00705"></a>00705 <span class="comment"> * </span>
<a name="l00706"></a>00706 <span class="comment"> *      ceil(n/b) = (n&gt;&gt;lb) + ( (n &amp; (b-1)) ? 1:0)</span>
<a name="l00707"></a>00707 <span class="comment"> * </span>
<a name="l00708"></a>00708 <span class="comment"> */</span>
<a name="l00709"></a><a class="code" href="uthash_8h.html#a6439fd6271474e61b1840fbf83132f03">00709</a> <span class="preprocessor">#define HASH_EXPAND_BUCKETS(tbl)                                                 \</span>
<a name="l00710"></a>00710 <span class="preprocessor">do {                                                                             \</span>
<a name="l00711"></a>00711 <span class="preprocessor">    unsigned _he_bkt;                                                            \</span>
<a name="l00712"></a>00712 <span class="preprocessor">    unsigned _he_bkt_i;                                                          \</span>
<a name="l00713"></a>00713 <span class="preprocessor">    struct UT_hash_handle *_he_thh, *_he_hh_nxt;                                 \</span>
<a name="l00714"></a>00714 <span class="preprocessor">    UT_hash_bucket *_he_new_buckets, *_he_newbkt;                                \</span>
<a name="l00715"></a>00715 <span class="preprocessor">    _he_new_buckets = (UT_hash_bucket*)uthash_malloc(                            \</span>
<a name="l00716"></a>00716 <span class="preprocessor">             2 * tbl-&gt;num_buckets * sizeof(struct UT_hash_bucket));              \</span>
<a name="l00717"></a>00717 <span class="preprocessor">    if (!_he_new_buckets) { uthash_fatal( &quot;out of memory&quot;); }                    \</span>
<a name="l00718"></a>00718 <span class="preprocessor">    memset(_he_new_buckets, 0,                                                   \</span>
<a name="l00719"></a>00719 <span class="preprocessor">            2 * tbl-&gt;num_buckets * sizeof(struct UT_hash_bucket));               \</span>
<a name="l00720"></a>00720 <span class="preprocessor">    tbl-&gt;ideal_chain_maxlen =                                                    \</span>
<a name="l00721"></a>00721 <span class="preprocessor">       (tbl-&gt;num_items &gt;&gt; (tbl-&gt;log2_num_buckets+1)) +                           \</span>
<a name="l00722"></a>00722 <span class="preprocessor">       ((tbl-&gt;num_items &amp; ((tbl-&gt;num_buckets*2)-1)) ? 1 : 0);                    \</span>
<a name="l00723"></a>00723 <span class="preprocessor">    tbl-&gt;nonideal_items = 0;                                                     \</span>
<a name="l00724"></a>00724 <span class="preprocessor">    for(_he_bkt_i = 0; _he_bkt_i &lt; tbl-&gt;num_buckets; _he_bkt_i++)                \</span>
<a name="l00725"></a>00725 <span class="preprocessor">    {                                                                            \</span>
<a name="l00726"></a>00726 <span class="preprocessor">        _he_thh = tbl-&gt;buckets[ _he_bkt_i ].hh_head;                             \</span>
<a name="l00727"></a>00727 <span class="preprocessor">        while (_he_thh) {                                                        \</span>
<a name="l00728"></a>00728 <span class="preprocessor">           _he_hh_nxt = _he_thh-&gt;hh_next;                                        \</span>
<a name="l00729"></a>00729 <span class="preprocessor">           HASH_TO_BKT( _he_thh-&gt;hashv, tbl-&gt;num_buckets*2, _he_bkt);            \</span>
<a name="l00730"></a>00730 <span class="preprocessor">           _he_newbkt = &amp;(_he_new_buckets[ _he_bkt ]);                           \</span>
<a name="l00731"></a>00731 <span class="preprocessor">           if (++(_he_newbkt-&gt;count) &gt; tbl-&gt;ideal_chain_maxlen) {                \</span>
<a name="l00732"></a>00732 <span class="preprocessor">             tbl-&gt;nonideal_items++;                                              \</span>
<a name="l00733"></a>00733 <span class="preprocessor">             _he_newbkt-&gt;expand_mult = _he_newbkt-&gt;count /                       \</span>
<a name="l00734"></a>00734 <span class="preprocessor">                                        tbl-&gt;ideal_chain_maxlen;                 \</span>
<a name="l00735"></a>00735 <span class="preprocessor">           }                                                                     \</span>
<a name="l00736"></a>00736 <span class="preprocessor">           _he_thh-&gt;hh_prev = NULL;                                              \</span>
<a name="l00737"></a>00737 <span class="preprocessor">           _he_thh-&gt;hh_next = _he_newbkt-&gt;hh_head;                               \</span>
<a name="l00738"></a>00738 <span class="preprocessor">           if (_he_newbkt-&gt;hh_head) _he_newbkt-&gt;hh_head-&gt;hh_prev =               \</span>
<a name="l00739"></a>00739 <span class="preprocessor">                _he_thh;                                                         \</span>
<a name="l00740"></a>00740 <span class="preprocessor">           _he_newbkt-&gt;hh_head = _he_thh;                                        \</span>
<a name="l00741"></a>00741 <span class="preprocessor">           _he_thh = _he_hh_nxt;                                                 \</span>
<a name="l00742"></a>00742 <span class="preprocessor">        }                                                                        \</span>
<a name="l00743"></a>00743 <span class="preprocessor">    }                                                                            \</span>
<a name="l00744"></a>00744 <span class="preprocessor">    uthash_free( tbl-&gt;buckets, tbl-&gt;num_buckets*sizeof(struct UT_hash_bucket) ); \</span>
<a name="l00745"></a>00745 <span class="preprocessor">    tbl-&gt;num_buckets *= 2;                                                       \</span>
<a name="l00746"></a>00746 <span class="preprocessor">    tbl-&gt;log2_num_buckets++;                                                     \</span>
<a name="l00747"></a>00747 <span class="preprocessor">    tbl-&gt;buckets = _he_new_buckets;                                              \</span>
<a name="l00748"></a>00748 <span class="preprocessor">    tbl-&gt;ineff_expands = (tbl-&gt;nonideal_items &gt; (tbl-&gt;num_items &gt;&gt; 1)) ?         \</span>
<a name="l00749"></a>00749 <span class="preprocessor">        (tbl-&gt;ineff_expands+1) : 0;                                              \</span>
<a name="l00750"></a>00750 <span class="preprocessor">    if (tbl-&gt;ineff_expands &gt; 1) {                                                \</span>
<a name="l00751"></a>00751 <span class="preprocessor">        tbl-&gt;noexpand=1;                                                         \</span>
<a name="l00752"></a>00752 <span class="preprocessor">        uthash_noexpand_fyi(tbl);                                                \</span>
<a name="l00753"></a>00753 <span class="preprocessor">    }                                                                            \</span>
<a name="l00754"></a>00754 <span class="preprocessor">    uthash_expand_fyi(tbl);                                                      \</span>
<a name="l00755"></a>00755 <span class="preprocessor">} while(0)</span>
<a name="l00756"></a>00756 <span class="preprocessor"></span>
<a name="l00757"></a>00757 
<a name="l00758"></a>00758 <span class="comment">/* This is an adaptation of Simon Tatham&#39;s O(n log(n)) mergesort */</span>
<a name="l00759"></a>00759 <span class="comment">/* Note that HASH_SORT assumes the hash handle name to be hh. </span>
<a name="l00760"></a>00760 <span class="comment"> * HASH_SRT was added to allow the hash handle name to be passed in. */</span>
<a name="l00761"></a><a class="code" href="uthash_8h.html#a88d2ab40956878caacd02c214f7e8f15">00761</a> <span class="preprocessor">#define HASH_SORT(head,cmpfcn) HASH_SRT(hh,head,cmpfcn)</span>
<a name="l00762"></a><a class="code" href="uthash_8h.html#a388b4071dcff005154f431d3d3025fbd">00762</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_SRT(hh,head,cmpfcn)                                                 \</span>
<a name="l00763"></a>00763 <span class="preprocessor">do {                                                                             \</span>
<a name="l00764"></a>00764 <span class="preprocessor">  unsigned _hs_i;                                                                \</span>
<a name="l00765"></a>00765 <span class="preprocessor">  unsigned _hs_looping,_hs_nmerges,_hs_insize,_hs_psize,_hs_qsize;               \</span>
<a name="l00766"></a>00766 <span class="preprocessor">  struct UT_hash_handle *_hs_p, *_hs_q, *_hs_e, *_hs_list, *_hs_tail;            \</span>
<a name="l00767"></a>00767 <span class="preprocessor">  if (head) {                                                                    \</span>
<a name="l00768"></a>00768 <span class="preprocessor">      _hs_insize = 1;                                                            \</span>
<a name="l00769"></a>00769 <span class="preprocessor">      _hs_looping = 1;                                                           \</span>
<a name="l00770"></a>00770 <span class="preprocessor">      _hs_list = &amp;((head)-&gt;hh);                                                  \</span>
<a name="l00771"></a>00771 <span class="preprocessor">      while (_hs_looping) {                                                      \</span>
<a name="l00772"></a>00772 <span class="preprocessor">          _hs_p = _hs_list;                                                      \</span>
<a name="l00773"></a>00773 <span class="preprocessor">          _hs_list = NULL;                                                       \</span>
<a name="l00774"></a>00774 <span class="preprocessor">          _hs_tail = NULL;                                                       \</span>
<a name="l00775"></a>00775 <span class="preprocessor">          _hs_nmerges = 0;                                                       \</span>
<a name="l00776"></a>00776 <span class="preprocessor">          while (_hs_p) {                                                        \</span>
<a name="l00777"></a>00777 <span class="preprocessor">              _hs_nmerges++;                                                     \</span>
<a name="l00778"></a>00778 <span class="preprocessor">              _hs_q = _hs_p;                                                     \</span>
<a name="l00779"></a>00779 <span class="preprocessor">              _hs_psize = 0;                                                     \</span>
<a name="l00780"></a>00780 <span class="preprocessor">              for ( _hs_i = 0; _hs_i  &lt; _hs_insize; _hs_i++ ) {                  \</span>
<a name="l00781"></a>00781 <span class="preprocessor">                  _hs_psize++;                                                   \</span>
<a name="l00782"></a>00782 <span class="preprocessor">                  _hs_q = (UT_hash_handle*)((_hs_q-&gt;next) ?                      \</span>
<a name="l00783"></a>00783 <span class="preprocessor">                          ((void*)((char*)(_hs_q-&gt;next) +                        \</span>
<a name="l00784"></a>00784 <span class="preprocessor">                          (head)-&gt;hh.tbl-&gt;hho)) : NULL);                         \</span>
<a name="l00785"></a>00785 <span class="preprocessor">                  if (! (_hs_q) ) break;                                         \</span>
<a name="l00786"></a>00786 <span class="preprocessor">              }                                                                  \</span>
<a name="l00787"></a>00787 <span class="preprocessor">              _hs_qsize = _hs_insize;                                            \</span>
<a name="l00788"></a>00788 <span class="preprocessor">              while ((_hs_psize &gt; 0) || ((_hs_qsize &gt; 0) &amp;&amp; _hs_q )) {           \</span>
<a name="l00789"></a>00789 <span class="preprocessor">                  if (_hs_psize == 0) {                                          \</span>
<a name="l00790"></a>00790 <span class="preprocessor">                      _hs_e = _hs_q;                                             \</span>
<a name="l00791"></a>00791 <span class="preprocessor">                      _hs_q = (UT_hash_handle*)((_hs_q-&gt;next) ?                  \</span>
<a name="l00792"></a>00792 <span class="preprocessor">                              ((void*)((char*)(_hs_q-&gt;next) +                    \</span>
<a name="l00793"></a>00793 <span class="preprocessor">                              (head)-&gt;hh.tbl-&gt;hho)) : NULL);                     \</span>
<a name="l00794"></a>00794 <span class="preprocessor">                      _hs_qsize--;                                               \</span>
<a name="l00795"></a>00795 <span class="preprocessor">                  } else if ( (_hs_qsize == 0) || !(_hs_q) ) {                   \</span>
<a name="l00796"></a>00796 <span class="preprocessor">                      _hs_e = _hs_p;                                             \</span>
<a name="l00797"></a>00797 <span class="preprocessor">                      _hs_p = (UT_hash_handle*)((_hs_p-&gt;next) ?                  \</span>
<a name="l00798"></a>00798 <span class="preprocessor">                              ((void*)((char*)(_hs_p-&gt;next) +                    \</span>
<a name="l00799"></a>00799 <span class="preprocessor">                              (head)-&gt;hh.tbl-&gt;hho)) : NULL);                     \</span>
<a name="l00800"></a>00800 <span class="preprocessor">                      _hs_psize--;                                               \</span>
<a name="l00801"></a>00801 <span class="preprocessor">                  } else if ((                                                   \</span>
<a name="l00802"></a>00802 <span class="preprocessor">                      cmpfcn(DECLTYPE(head)(ELMT_FROM_HH((head)-&gt;hh.tbl,_hs_p)), \</span>
<a name="l00803"></a>00803 <span class="preprocessor">                             DECLTYPE(head)(ELMT_FROM_HH((head)-&gt;hh.tbl,_hs_q))) \</span>
<a name="l00804"></a>00804 <span class="preprocessor">                             ) &lt;= 0) {                                           \</span>
<a name="l00805"></a>00805 <span class="preprocessor">                      _hs_e = _hs_p;                                             \</span>
<a name="l00806"></a>00806 <span class="preprocessor">                      _hs_p = (UT_hash_handle*)((_hs_p-&gt;next) ?                  \</span>
<a name="l00807"></a>00807 <span class="preprocessor">                              ((void*)((char*)(_hs_p-&gt;next) +                    \</span>
<a name="l00808"></a>00808 <span class="preprocessor">                              (head)-&gt;hh.tbl-&gt;hho)) : NULL);                     \</span>
<a name="l00809"></a>00809 <span class="preprocessor">                      _hs_psize--;                                               \</span>
<a name="l00810"></a>00810 <span class="preprocessor">                  } else {                                                       \</span>
<a name="l00811"></a>00811 <span class="preprocessor">                      _hs_e = _hs_q;                                             \</span>
<a name="l00812"></a>00812 <span class="preprocessor">                      _hs_q = (UT_hash_handle*)((_hs_q-&gt;next) ?                  \</span>
<a name="l00813"></a>00813 <span class="preprocessor">                              ((void*)((char*)(_hs_q-&gt;next) +                    \</span>
<a name="l00814"></a>00814 <span class="preprocessor">                              (head)-&gt;hh.tbl-&gt;hho)) : NULL);                     \</span>
<a name="l00815"></a>00815 <span class="preprocessor">                      _hs_qsize--;                                               \</span>
<a name="l00816"></a>00816 <span class="preprocessor">                  }                                                              \</span>
<a name="l00817"></a>00817 <span class="preprocessor">                  if ( _hs_tail ) {                                              \</span>
<a name="l00818"></a>00818 <span class="preprocessor">                      _hs_tail-&gt;next = ((_hs_e) ?                                \</span>
<a name="l00819"></a>00819 <span class="preprocessor">                            ELMT_FROM_HH((head)-&gt;hh.tbl,_hs_e) : NULL);          \</span>
<a name="l00820"></a>00820 <span class="preprocessor">                  } else {                                                       \</span>
<a name="l00821"></a>00821 <span class="preprocessor">                      _hs_list = _hs_e;                                          \</span>
<a name="l00822"></a>00822 <span class="preprocessor">                  }                                                              \</span>
<a name="l00823"></a>00823 <span class="preprocessor">                  _hs_e-&gt;prev = ((_hs_tail) ?                                    \</span>
<a name="l00824"></a>00824 <span class="preprocessor">                     ELMT_FROM_HH((head)-&gt;hh.tbl,_hs_tail) : NULL);              \</span>
<a name="l00825"></a>00825 <span class="preprocessor">                  _hs_tail = _hs_e;                                              \</span>
<a name="l00826"></a>00826 <span class="preprocessor">              }                                                                  \</span>
<a name="l00827"></a>00827 <span class="preprocessor">              _hs_p = _hs_q;                                                     \</span>
<a name="l00828"></a>00828 <span class="preprocessor">          }                                                                      \</span>
<a name="l00829"></a>00829 <span class="preprocessor">          _hs_tail-&gt;next = NULL;                                                 \</span>
<a name="l00830"></a>00830 <span class="preprocessor">          if ( _hs_nmerges &lt;= 1 ) {                                              \</span>
<a name="l00831"></a>00831 <span class="preprocessor">              _hs_looping=0;                                                     \</span>
<a name="l00832"></a>00832 <span class="preprocessor">              (head)-&gt;hh.tbl-&gt;tail = _hs_tail;                                   \</span>
<a name="l00833"></a>00833 <span class="preprocessor">              DECLTYPE_ASSIGN(head,ELMT_FROM_HH((head)-&gt;hh.tbl, _hs_list));      \</span>
<a name="l00834"></a>00834 <span class="preprocessor">          }                                                                      \</span>
<a name="l00835"></a>00835 <span class="preprocessor">          _hs_insize *= 2;                                                       \</span>
<a name="l00836"></a>00836 <span class="preprocessor">      }                                                                          \</span>
<a name="l00837"></a>00837 <span class="preprocessor">      HASH_FSCK(hh,head);                                                        \</span>
<a name="l00838"></a>00838 <span class="preprocessor"> }                                                                               \</span>
<a name="l00839"></a>00839 <span class="preprocessor">} while (0)</span>
<a name="l00840"></a>00840 <span class="preprocessor"></span>
<a name="l00841"></a>00841 <span class="comment">/* This function selects items from one hash into another hash. </span>
<a name="l00842"></a>00842 <span class="comment"> * The end result is that the selected items have dual presence </span>
<a name="l00843"></a>00843 <span class="comment"> * in both hashes. There is no copy of the items made; rather </span>
<a name="l00844"></a>00844 <span class="comment"> * they are added into the new hash through a secondary hash </span>
<a name="l00845"></a>00845 <span class="comment"> * hash handle that must be present in the structure. */</span>
<a name="l00846"></a><a class="code" href="uthash_8h.html#ad190366f7a476ece79bd628240a5fc93">00846</a> <span class="preprocessor">#define HASH_SELECT(hh_dst, dst, hh_src, src, cond)                              \</span>
<a name="l00847"></a>00847 <span class="preprocessor">do {                                                                             \</span>
<a name="l00848"></a>00848 <span class="preprocessor">  unsigned _src_bkt, _dst_bkt;                                                   \</span>
<a name="l00849"></a>00849 <span class="preprocessor">  void *_last_elt=NULL, *_elt;                                                   \</span>
<a name="l00850"></a>00850 <span class="preprocessor">  UT_hash_handle *_src_hh, *_dst_hh, *_last_elt_hh=NULL;                         \</span>
<a name="l00851"></a>00851 <span class="preprocessor">  ptrdiff_t _dst_hho = ((char*)(&amp;(dst)-&gt;hh_dst) - (char*)(dst));                 \</span>
<a name="l00852"></a>00852 <span class="preprocessor">  if (src) {                                                                     \</span>
<a name="l00853"></a>00853 <span class="preprocessor">    for(_src_bkt=0; _src_bkt &lt; (src)-&gt;hh_src.tbl-&gt;num_buckets; _src_bkt++) {     \</span>
<a name="l00854"></a>00854 <span class="preprocessor">      for(_src_hh = (src)-&gt;hh_src.tbl-&gt;buckets[_src_bkt].hh_head;                \</span>
<a name="l00855"></a>00855 <span class="preprocessor">          _src_hh;                                                               \</span>
<a name="l00856"></a>00856 <span class="preprocessor">          _src_hh = _src_hh-&gt;hh_next) {                                          \</span>
<a name="l00857"></a>00857 <span class="preprocessor">          _elt = ELMT_FROM_HH((src)-&gt;hh_src.tbl, _src_hh);                       \</span>
<a name="l00858"></a>00858 <span class="preprocessor">          if (cond(_elt)) {                                                      \</span>
<a name="l00859"></a>00859 <span class="preprocessor">            _dst_hh = (UT_hash_handle*)(((char*)_elt) + _dst_hho);               \</span>
<a name="l00860"></a>00860 <span class="preprocessor">            _dst_hh-&gt;key = _src_hh-&gt;key;                                         \</span>
<a name="l00861"></a>00861 <span class="preprocessor">            _dst_hh-&gt;keylen = _src_hh-&gt;keylen;                                   \</span>
<a name="l00862"></a>00862 <span class="preprocessor">            _dst_hh-&gt;hashv = _src_hh-&gt;hashv;                                     \</span>
<a name="l00863"></a>00863 <span class="preprocessor">            _dst_hh-&gt;prev = _last_elt;                                           \</span>
<a name="l00864"></a>00864 <span class="preprocessor">            _dst_hh-&gt;next = NULL;                                                \</span>
<a name="l00865"></a>00865 <span class="preprocessor">            if (_last_elt_hh) { _last_elt_hh-&gt;next = _elt; }                     \</span>
<a name="l00866"></a>00866 <span class="preprocessor">            if (!dst) {                                                          \</span>
<a name="l00867"></a>00867 <span class="preprocessor">              DECLTYPE_ASSIGN(dst,_elt);                                         \</span>
<a name="l00868"></a>00868 <span class="preprocessor">              HASH_MAKE_TABLE(hh_dst,dst);                                       \</span>
<a name="l00869"></a>00869 <span class="preprocessor">            } else {                                                             \</span>
<a name="l00870"></a>00870 <span class="preprocessor">              _dst_hh-&gt;tbl = (dst)-&gt;hh_dst.tbl;                                  \</span>
<a name="l00871"></a>00871 <span class="preprocessor">            }                                                                    \</span>
<a name="l00872"></a>00872 <span class="preprocessor">            HASH_TO_BKT(_dst_hh-&gt;hashv, _dst_hh-&gt;tbl-&gt;num_buckets, _dst_bkt);    \</span>
<a name="l00873"></a>00873 <span class="preprocessor">            HASH_ADD_TO_BKT(_dst_hh-&gt;tbl-&gt;buckets[_dst_bkt],_dst_hh);            \</span>
<a name="l00874"></a>00874 <span class="preprocessor">            (dst)-&gt;hh_dst.tbl-&gt;num_items++;                                      \</span>
<a name="l00875"></a>00875 <span class="preprocessor">            _last_elt = _elt;                                                    \</span>
<a name="l00876"></a>00876 <span class="preprocessor">            _last_elt_hh = _dst_hh;                                              \</span>
<a name="l00877"></a>00877 <span class="preprocessor">          }                                                                      \</span>
<a name="l00878"></a>00878 <span class="preprocessor">      }                                                                          \</span>
<a name="l00879"></a>00879 <span class="preprocessor">    }                                                                            \</span>
<a name="l00880"></a>00880 <span class="preprocessor">  }                                                                              \</span>
<a name="l00881"></a>00881 <span class="preprocessor">  HASH_FSCK(hh_dst,dst);                                                         \</span>
<a name="l00882"></a>00882 <span class="preprocessor">} while (0)</span>
<a name="l00883"></a>00883 <span class="preprocessor"></span>
<a name="l00884"></a><a class="code" href="uthash_8h.html#a0512b3f7a824275579ec82643ef2cc23">00884</a> <span class="preprocessor">#define HASH_CLEAR(hh,head)                                                      \</span>
<a name="l00885"></a>00885 <span class="preprocessor">do {                                                                             \</span>
<a name="l00886"></a>00886 <span class="preprocessor">  if (head) {                                                                    \</span>
<a name="l00887"></a>00887 <span class="preprocessor">    uthash_free((head)-&gt;hh.tbl-&gt;buckets,                                         \</span>
<a name="l00888"></a>00888 <span class="preprocessor">                (head)-&gt;hh.tbl-&gt;num_buckets*sizeof(struct UT_hash_bucket));      \</span>
<a name="l00889"></a>00889 <span class="preprocessor">    uthash_free((head)-&gt;hh.tbl, sizeof(UT_hash_table));                          \</span>
<a name="l00890"></a>00890 <span class="preprocessor">    (head)=NULL;                                                                 \</span>
<a name="l00891"></a>00891 <span class="preprocessor">  }                                                                              \</span>
<a name="l00892"></a>00892 <span class="preprocessor">} while(0)</span>
<a name="l00893"></a>00893 <span class="preprocessor"></span>
<a name="l00894"></a>00894 <span class="preprocessor">#ifdef NO_DECLTYPE</span>
<a name="l00895"></a>00895 <span class="preprocessor"></span><span class="preprocessor">#define HASH_ITER(hh,head,el,tmp)                                                \</span>
<a name="l00896"></a>00896 <span class="preprocessor">for((el)=(head), (*(char**)(&amp;(tmp)))=(char*)((head)?(head)-&gt;hh.next:NULL);       \</span>
<a name="l00897"></a>00897 <span class="preprocessor">  el; (el)=(tmp),(*(char**)(&amp;(tmp)))=(char*)((tmp)?(tmp)-&gt;hh.next:NULL)) </span>
<a name="l00898"></a>00898 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00899"></a><a class="code" href="uthash_8h.html#a4d524042f1fcb976d8bccae9e4cc63d6">00899</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_ITER(hh,head,el,tmp)                                                \</span>
<a name="l00900"></a>00900 <span class="preprocessor">for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)-&gt;hh.next:NULL);                 \</span>
<a name="l00901"></a>00901 <span class="preprocessor">  el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)-&gt;hh.next:NULL))</span>
<a name="l00902"></a>00902 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00903"></a>00903 <span class="preprocessor"></span>
<a name="l00904"></a>00904 <span class="comment">/* obtain a count of items in the hash */</span>
<a name="l00905"></a><a class="code" href="uthash_8h.html#a7d3edf55a3ee4da1a0e1b477c314342f">00905</a> <span class="preprocessor">#define HASH_COUNT(head) HASH_CNT(hh,head) </span>
<a name="l00906"></a><a class="code" href="uthash_8h.html#a6ea9e661cd8c35eff1fdcd5731127edd">00906</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_CNT(hh,head) ((head)?((head)-&gt;hh.tbl-&gt;num_items):0)</span>
<a name="l00907"></a>00907 <span class="preprocessor"></span>
<a name="l00908"></a><a class="code" href="structUT__hash__bucket.html">00908</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structUT__hash__bucket.html">UT_hash_bucket</a> {
<a name="l00909"></a><a class="code" href="structUT__hash__bucket.html#a785a785132212378bb28fb4341cfecaf">00909</a>    <span class="keyword">struct </span><a class="code" href="structUT__hash__handle.html">UT_hash_handle</a> *<a class="code" href="structUT__hash__bucket.html#a785a785132212378bb28fb4341cfecaf">hh_head</a>;
<a name="l00910"></a><a class="code" href="structUT__hash__bucket.html#a5d20cc12bdcbde360398910eefb45634">00910</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__bucket.html#a5d20cc12bdcbde360398910eefb45634">count</a>;
<a name="l00911"></a>00911 
<a name="l00912"></a>00912    <span class="comment">/* expand_mult is normally set to 0. In this situation, the max chain length</span>
<a name="l00913"></a>00913 <span class="comment">    * threshold is enforced at its default value, HASH_BKT_CAPACITY_THRESH. (If</span>
<a name="l00914"></a>00914 <span class="comment">    * the bucket&#39;s chain exceeds this length, bucket expansion is triggered). </span>
<a name="l00915"></a>00915 <span class="comment">    * However, setting expand_mult to a non-zero value delays bucket expansion</span>
<a name="l00916"></a>00916 <span class="comment">    * (that would be triggered by additions to this particular bucket)</span>
<a name="l00917"></a>00917 <span class="comment">    * until its chain length reaches a *multiple* of HASH_BKT_CAPACITY_THRESH.</span>
<a name="l00918"></a>00918 <span class="comment">    * (The multiplier is simply expand_mult+1). The whole idea of this</span>
<a name="l00919"></a>00919 <span class="comment">    * multiplier is to reduce bucket expansions, since they are expensive, in</span>
<a name="l00920"></a>00920 <span class="comment">    * situations where we know that a particular bucket tends to be overused.</span>
<a name="l00921"></a>00921 <span class="comment">    * It is better to let its chain length grow to a longer yet-still-bounded</span>
<a name="l00922"></a>00922 <span class="comment">    * value, than to do an O(n) bucket expansion too often. </span>
<a name="l00923"></a>00923 <span class="comment">    */</span>
<a name="l00924"></a><a class="code" href="structUT__hash__bucket.html#a9b739c1b69c141e8198c0c64af643b2b">00924</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__bucket.html#a9b739c1b69c141e8198c0c64af643b2b">expand_mult</a>;
<a name="l00925"></a>00925 
<a name="l00926"></a>00926 } <a class="code" href="structUT__hash__bucket.html">UT_hash_bucket</a>;
<a name="l00927"></a>00927 
<a name="l00928"></a>00928 <span class="comment">/* random signature used only to find hash tables in external analysis */</span>
<a name="l00929"></a><a class="code" href="uthash_8h.html#a4a7a46b9b92a9c73e4f9321e8e6b6bb2">00929</a> <span class="preprocessor">#define HASH_SIGNATURE 0xa0111fe1</span>
<a name="l00930"></a><a class="code" href="uthash_8h.html#a18a33f4269f05c1e81ce54edbc0ffca6">00930</a> <span class="preprocessor"></span><span class="preprocessor">#define HASH_BLOOM_SIGNATURE 0xb12220f2</span>
<a name="l00931"></a>00931 <span class="preprocessor"></span>
<a name="l00932"></a><a class="code" href="structUT__hash__table.html">00932</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structUT__hash__table.html">UT_hash_table</a> {
<a name="l00933"></a><a class="code" href="structUT__hash__table.html#a04556bbef9c9a1c40b1bc0d17a2a6e0b">00933</a>    <a class="code" href="structUT__hash__bucket.html">UT_hash_bucket</a> *<a class="code" href="structUT__hash__table.html#a04556bbef9c9a1c40b1bc0d17a2a6e0b">buckets</a>;
<a name="l00934"></a><a class="code" href="structUT__hash__table.html#a3ed04b6233facaedf910672578d86339">00934</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__table.html#a3ed04b6233facaedf910672578d86339">num_buckets</a>, <a class="code" href="structUT__hash__table.html#ae376a7f3fac525f3a9d03b6beec8d12f">log2_num_buckets</a>;
<a name="l00935"></a><a class="code" href="structUT__hash__table.html#a74534cc14f080c96f94d8f5da83d9d76">00935</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__table.html#a74534cc14f080c96f94d8f5da83d9d76">num_items</a>;
<a name="l00936"></a><a class="code" href="structUT__hash__table.html#a00a889a5e1ebaeec0a83ec2701df1992">00936</a>    <span class="keyword">struct </span><a class="code" href="structUT__hash__handle.html">UT_hash_handle</a> *<a class="code" href="structUT__hash__table.html#a00a889a5e1ebaeec0a83ec2701df1992">tail</a>; <span class="comment">/* tail hh in app order, for fast append    */</span>
<a name="l00937"></a><a class="code" href="structUT__hash__table.html#afd05f4d9e45354fb010367ae9e1bddb6">00937</a>    ptrdiff_t <a class="code" href="structUT__hash__table.html#afd05f4d9e45354fb010367ae9e1bddb6">hho</a>; <span class="comment">/* hash handle offset (byte pos of hash handle in element */</span>
<a name="l00938"></a>00938 
<a name="l00939"></a>00939    <span class="comment">/* in an ideal situation (all buckets used equally), no bucket would have</span>
<a name="l00940"></a>00940 <span class="comment">    * more than ceil(#items/#buckets) items. that&#39;s the ideal chain length. */</span>
<a name="l00941"></a><a class="code" href="structUT__hash__table.html#a5f1cec93d5d753ba02097c797e4d67ad">00941</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__table.html#a5f1cec93d5d753ba02097c797e4d67ad">ideal_chain_maxlen</a>;
<a name="l00942"></a>00942 
<a name="l00943"></a>00943    <span class="comment">/* nonideal_items is the number of items in the hash whose chain position</span>
<a name="l00944"></a>00944 <span class="comment">    * exceeds the ideal chain maxlen. these items pay the penalty for an uneven</span>
<a name="l00945"></a>00945 <span class="comment">    * hash distribution; reaching them in a chain traversal takes &gt;ideal steps */</span>
<a name="l00946"></a><a class="code" href="structUT__hash__table.html#a8cb66cfb259a204cda59a815e4db664f">00946</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__table.html#a8cb66cfb259a204cda59a815e4db664f">nonideal_items</a>;
<a name="l00947"></a>00947 
<a name="l00948"></a>00948    <span class="comment">/* ineffective expands occur when a bucket doubling was performed, but </span>
<a name="l00949"></a>00949 <span class="comment">    * afterward, more than half the items in the hash had nonideal chain</span>
<a name="l00950"></a>00950 <span class="comment">    * positions. If this happens on two consecutive expansions we inhibit any</span>
<a name="l00951"></a>00951 <span class="comment">    * further expansion, as it&#39;s not helping; this happens when the hash</span>
<a name="l00952"></a>00952 <span class="comment">    * function isn&#39;t a good fit for the key domain. When expansion is inhibited</span>
<a name="l00953"></a>00953 <span class="comment">    * the hash will still work, albeit no longer in constant time. */</span>
<a name="l00954"></a><a class="code" href="structUT__hash__table.html#a635661789933752e7b83dac84430eae1">00954</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__table.html#a216c7d98cf40a0064bee94aa8a5bf1b7">ineff_expands</a>, <a class="code" href="structUT__hash__table.html#a635661789933752e7b83dac84430eae1">noexpand</a>;
<a name="l00955"></a>00955 
<a name="l00956"></a><a class="code" href="structUT__hash__table.html#a87d1ab3f3ede1809c6a485972d20b25f">00956</a>    uint32_t <a class="code" href="structUT__hash__table.html#a87d1ab3f3ede1809c6a485972d20b25f">signature</a>; <span class="comment">/* used only to find hash tables in external analysis */</span>
<a name="l00957"></a>00957 <span class="preprocessor">#ifdef HASH_BLOOM</span>
<a name="l00958"></a>00958 <span class="preprocessor"></span>   uint32_t bloom_sig; <span class="comment">/* used only to test bloom exists in external analysis */</span>
<a name="l00959"></a>00959    uint8_t *bloom_bv;
<a name="l00960"></a>00960    <span class="keywordtype">char</span> bloom_nbits;
<a name="l00961"></a>00961 <span class="preprocessor">#endif</span>
<a name="l00962"></a>00962 <span class="preprocessor"></span>
<a name="l00963"></a>00963 } <a class="code" href="structUT__hash__table.html">UT_hash_table</a>;
<a name="l00964"></a>00964 
<a name="l00965"></a><a class="code" href="structUT__hash__handle.html">00965</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structUT__hash__handle.html">UT_hash_handle</a> {
<a name="l00966"></a><a class="code" href="structUT__hash__handle.html#ad2035ee3b2aa55b22e352341372a5e73">00966</a>    <span class="keyword">struct </span><a class="code" href="structUT__hash__table.html">UT_hash_table</a> *<a class="code" href="structUT__hash__handle.html#ad2035ee3b2aa55b22e352341372a5e73">tbl</a>;
<a name="l00967"></a><a class="code" href="structUT__hash__handle.html#abaf54a69367933df2d45575f48ca6a58">00967</a>    <span class="keywordtype">void</span> *<a class="code" href="structUT__hash__handle.html#abaf54a69367933df2d45575f48ca6a58">prev</a>;                       <span class="comment">/* prev element in app order      */</span>
<a name="l00968"></a><a class="code" href="structUT__hash__handle.html#a93bc88ffe97f85ea0d9e0056b7118942">00968</a>    <span class="keywordtype">void</span> *<a class="code" href="structUT__hash__handle.html#a93bc88ffe97f85ea0d9e0056b7118942">next</a>;                       <span class="comment">/* next element in app order      */</span>
<a name="l00969"></a><a class="code" href="structUT__hash__handle.html#a3ec03e34d7975d5c1981c44b324619b2">00969</a>    <span class="keyword">struct </span><a class="code" href="structUT__hash__handle.html">UT_hash_handle</a> *<a class="code" href="structUT__hash__handle.html#a3ec03e34d7975d5c1981c44b324619b2">hh_prev</a>;   <span class="comment">/* previous hh in bucket order    */</span>
<a name="l00970"></a><a class="code" href="structUT__hash__handle.html#a4f6989385499ba6f594b0f0facd28325">00970</a>    <span class="keyword">struct </span><a class="code" href="structUT__hash__handle.html">UT_hash_handle</a> *<a class="code" href="structUT__hash__handle.html#a4f6989385499ba6f594b0f0facd28325">hh_next</a>;   <span class="comment">/* next hh in bucket order        */</span>
<a name="l00971"></a><a class="code" href="structUT__hash__handle.html#a40690fc15aeaeba8f25385f05f84dd4d">00971</a>    <span class="keywordtype">void</span> *<a class="code" href="structUT__hash__handle.html#a40690fc15aeaeba8f25385f05f84dd4d">key</a>;                        <span class="comment">/* ptr to enclosing struct&#39;s key  */</span>
<a name="l00972"></a><a class="code" href="structUT__hash__handle.html#af2abdc405972a6bbdee2ade2c0f346c4">00972</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__handle.html#af2abdc405972a6bbdee2ade2c0f346c4">keylen</a>;                  <span class="comment">/* enclosing struct&#39;s key len     */</span>
<a name="l00973"></a><a class="code" href="structUT__hash__handle.html#aae5e635fa110556e5007f627089f8323">00973</a>    <span class="keywordtype">unsigned</span> <a class="code" href="structUT__hash__handle.html#aae5e635fa110556e5007f627089f8323">hashv</a>;                   <span class="comment">/* result of hash-fcn(key)        */</span>
<a name="l00974"></a>00974 } <a class="code" href="structUT__hash__handle.html">UT_hash_handle</a>;
<a name="l00975"></a>00975 
<a name="l00976"></a>00976 <span class="preprocessor">#endif </span><span class="comment">/* UTHASH_H */</span>
</pre></div></div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>Todo</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Estructuras de Datos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Archivos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Funciones</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Tipos definidos</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Definiciones</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address style="text-align: right;"><small>Generado el Mon Jun 6 20:15:28 2011 para dinic por&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>
